• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyberShadow / aconfmgr / 373

02 Dec 2023 10:51AM UTC coverage: 84.045% (-9.6%) from 93.666%
373

push

github

CyberShadow-Renovate
Update dependency paru to v20231201221822

0 of 1 new or added line in 1 file covered. (0.0%)

410 existing lines in 22 files now uncovered.

3777 of 4494 relevant lines covered (84.05%)

145.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.0
/test/t/lib-funcs-common.bash
1
# Test case configuration functions (common)
2

3
###############################################################################
4
# Test preconditions
5

6
function TestMockOnly() {
7
        if ((${ACONFMGR_INTEGRATION:-0}))
×
8
        then
9
                LogLeave
×
10
                LogLeave 'Skipping (mock-only test).\n'
×
11
                printf '\n' 1>&2 # Leave a blank line between tests
×
12
                Exit 0
×
13
        fi
14
}
15

16
function TestIntegrationOnly() {
17
        if ! ((${ACONFMGR_INTEGRATION:-0}))
17✔
18
        then
19
                LogLeave
15✔
20
                LogLeave 'Skipping (integration-only test).\n'
15✔
21
                printf '\n' 1>&2 # Leave a blank line between tests
15✔
22
                Exit 0
15✔
23
        fi
24
}
25

26
function TestNeedRoot() {
27
        TestIntegrationOnly
1✔
28

UNCOV
29
        if [[ "$EUID" != 0 ]]
×
30
        then
UNCOV
31
                Log 'Re-executing as root ...\n'
×
UNCOV
32
                exec sudo -E -C 1000 "$0"
×
33
        else
34
                HOME=/root # Ensure ~/.ssh is set up properly for AUR
×
35
        fi
36
}
37

38
function TestNeedAUR() {
39
        TestIntegrationOnly
15✔
40
        TestInitAUR
2✔
41
}
42

43
###############################################################################
44
# Test phases
45

46
function TestPhase_Setup() {
47
        LogLeave
71✔
48
        LogEnter 'Setting up test case...\n'
71✔
49
}
50

51
function TestPhase_Run() {
52
        LogLeave
75✔
53
        LogEnter 'Running test...\n'
75✔
54
        TestPhase_RunHook
75✔
55
}
56

57
function TestPhase_Check() {
58
        LogLeave
74✔
59
        LogEnter 'Checking results...\n'
74✔
60
}
61

62
test_globals_whitelist=(
63

64
        # Set by bash
65
        COLUMNS
×
66
        LINES
×
67
        FUNCNAME
×
68
        BASH_REMATCH
×
69

70
        # Terminal codes (common.bash)
71
        ANSI_clear_line
×
72
        ANSI_color_B
×
73
        ANSI_color_C
×
74
        ANSI_color_G
×
75
        ANSI_color_M
×
76
        ANSI_color_R
×
77
        ANSI_color_W
×
78
        ANSI_color_Y
×
79
        ANSI_reset
×
80

81
        # Defaults inherited from environment (common.bash)
82
        PACMAN
×
83

84
        # Command-line settings
85
        aconfmgr_action
×
86
        aconfmgr_action_args
×
87
        aur_helper
×
88
        prompt_mode
×
89
        skip_config
×
90
        skip_inspection
×
91
        skip_checksums
×
92
        verbose
×
93

94
        # Config-tweakable settings
95
        default_file_mode
×
96
        ignore_paths
×
97
        priority_files
×
98
        file_content_filters
×
99
        makepkg_user
×
100

101
        warn_file_count_threshold
×
102
        warn_size_threshold
×
103
        warn_tmp_df_threshold
×
104

105
        # Internal state (paths)
106
        config_dir
×
107
        output_dir
×
108
        system_dir
×
109
        tmp_dir
×
110
        aur_dir
×
111

112
        # Internal state (AconfAnalyzeFiles)
113
        system_only_files
×
114
        changed_files
×
115
        config_only_files
×
116
        output_file_props
×
117
        system_file_props
×
118
        orig_file_props
×
119
        all_file_property_kinds
×
120

121
        # Internal state (AconfCompareFileProps)
122
        system_only_file_props
×
123
        changed_file_props
×
124
        config_only_file_props
×
125

126
        # Internal state (AconfCompile)
127
        packages
×
128
        installed_packages
×
129
        foreign_packages
×
130
        installed_foreign_packages
×
131

132
        # Internal state (AconfCompileOutput)
133
        ignore_packages
×
134
        ignore_foreign_packages
×
135
        used_files
×
136

137
        # Internal state (AconfCompileSystem)
138
        ignored_dirs
×
139

140
        # Internal state (misc.)
141
        aur_helpers
×
142
        base_devel_installed
×
143
        lint_config
×
144
        log_indent
×
145
        file_property_kind_exists
×
146

147
        # Tool command-line options
148
        aurman_opts
×
149
        diff_opts
×
150
        makepkg_opts
×
151
        pacaur_opts
×
152
        pacman_opts
×
153
        yaourt_opts
×
154
        yay_opts
×
155
        paru_opts
×
156

157
        # Test suite
158
        test_name
×
159
        test_dir
×
160
        test_data_dir
×
161
        test_aur_dir
×
162
        test_fs_root
×
163
        test_globals_initial
×
164
        test_globals_whitelist
×
165
        test_adopted_packages
×
166
        test_expected_warnings
×
167
)
90✔
168

169
declare -i test_expected_warnings=0
90✔
170

171
function TestDone() {
172
        LogLeave
75✔
173

174
        # Final checks
175

176
        # Check that log nesting level is balanced
177
        test "$log_indent" == :: || FatalError 'Unbalanced log level!\n'
75✔
178

179
        # Check for stray global variables
180
        (
181
                comm -13 <(compgen -e | sort) <(compgen -v | sort) \
375✔
182
                        | comm -23 /dev/stdin <(echo "$test_globals_initial") \
150✔
183
                        | comm -23 /dev/stdin <(echo "${test_globals_whitelist[*]}" | sort) \
225✔
184
                        | diff /dev/null /dev/stdin
75✔
185
        ) || FatalError 'Unknown stray global variables found!\n'
×
186

187
        # Check that the warning count is as expected
188
        local -i config_warnings
75✔
189
        if [[ -e "$output_dir"/warnings ]]
75✔
190
        then
191
                config_warnings=$(stat --format=%s "$output_dir"/warnings)
148✔
192
        else
193
                config_warnings=0
1✔
194
        fi
195
        test "$config_warnings" -eq "$test_expected_warnings" || \
75✔
196
                FatalError 'Unexpected warning count: expected %s, encountered %s\n' \
×
197
                                   "$(Color G "$test_expected_warnings")" \
×
198
                                   "$(Color G "$config_warnings")"
×
199

200
        # Check that the temporary directory is created with the correct permissions
201
        local tmp_dir_mode
75✔
202
        if [[ -d "$tmp_dir" ]]
75✔
203
        then
204
                tmp_dir_mode=$(stat --format=%a "$tmp_dir")
148✔
205
                if [[ "$tmp_dir_mode" != 700 ]]
74✔
206
                then
207
                        FatalError '%q has mode %s, not 700!\n' "$tmp_dir" "$tmp_dir_mode"
×
208
                fi
209
        fi
210

211
        LogLeave 'Test %s: %s!\n' "$(Color C "$test_name")" "$(Color G success)"
225✔
212
        if [[ -v GITHUB_ACTIONS ]] ; then printf '::endgroup::\n' 1>&2 ; fi
150✔
213
        printf '\n' 1>&2 # Leave a blank line between tests
75✔
214
        Exit 0
75✔
215
}
216

217
###############################################################################
218
# Files
219

220
# Helper function - create path to and write file
221
function TestWriteFile() {
222
        local fn=$1
574✔
223
        local data=$2
574✔
224

225
        mkdir -p "$(dirname "$fn")"
1,148✔
226
        printf "%s" "$data" > "$fn"
574✔
227
}
228

229
# Add a file to the virtual filesystem.
230
function TestAddFile() {
231
        local path=$1
46✔
232
        local contents=$2
46✔
233
        local mode=${3:-}
46✔
234
        local owner=${4:-}
46✔
235
        local group=${5:-}
46✔
236
        local mtime=${6:-}
46✔
237

238
        TestAddFSObj '' "$path" file "$contents" "$mode" "$owner" "$group" "$mtime"
46✔
239
}
240

241
# Add a directory to the virtual filesystem.
242
function TestAddDir() {
243
        local path=$1
4✔
244
        local mode=${2:-}
4✔
245
        local owner=${3:-}
4✔
246
        local group=${4:-}
4✔
247
        local mtime=${5:-}
4✔
248

249
        TestAddFSObj '' "$path" dir '' "$mode" "$owner" "$group" "$mtime"
4✔
250
}
251

252
# Add a symlink to the virtual filesystem.
253
function TestAddLink() {
254
        local path=$1
1✔
255
        local target=$2
1✔
256
        local owner=${3:-}
1✔
257
        local group=${4:-}
1✔
258
        local mtime=${5:-}
1✔
259

260
        TestAddFSObj '' "$path" link "$target" '' "$owner" "$group" "$mtime"
1✔
261
}
262

263
function TestAddPackageFile() {
264
        local package=$1
397✔
265
        local path=$2
397✔
266
        local contents=$3
397✔
267
        local mode=${4:-}
397✔
268
        local owner=${5:-}
397✔
269
        local group=${6:-}
397✔
270
        local mtime=${7:-}
397✔
271

272
        TestAddFSObj "$package" "$path" file "$contents" "$mode" "$owner" "$group" "$mtime"
397✔
273
}
274

275
function TestAddPackageDir() {
276
        local package=$1
7✔
277
        local path=$2
7✔
278
        local mode=${3:-}
7✔
279
        local owner=${4:-}
7✔
280
        local group=${5:-}
7✔
281
        local mtime=${6:-}
7✔
282

283
        TestAddFSObj "$package" "$path" dir '' "$mode" "$owner" "$group" "$mtime"
7✔
284
}
285

286
###############################################################################
287
# Packages
288

289
# Helper function - shorthand for creating and "installing" a package.
290
function TestAddPackage() {
291
        local package=$1
30✔
292
        local kind=$2
30✔
293
        local inst_as=$3
30✔
294

295
        TestCreatePackage "$package" "$kind"
30✔
296
        TestInstallPackage "$package" "$kind" "$inst_as"
30✔
297
}
298

299

300
###############################################################################
301
# Configuration
302

303
# Add a line to the configuration
304
function TestAddConfig() {
305
        (
306
                printf "%s " "$@"
257✔
307
                printf '\n'
257✔
308
        ) >> "$config_dir"/50-aconfmgr-test-config.sh
×
309
}
310

311
# Verify that the generated 99-unsorted.sh configuration, stripped of
312
# blank and comment lines, matches stdin.
313
function TestExpectConfig() {
314
        touch "$config_dir"/99-unsorted.sh
23✔
315
        diff -u /dev/stdin <(grep '^[^#]' "$config_dir"/99-unsorted.sh || true)
54✔
316
}
317

318
###############################################################################
319
# Test suite overrides
320

321
prompt_mode=paranoid
90✔
322
function Confirm() {
323
        local detail_func="$1"
109✔
324

325
        if [[ -n "$detail_func" ]]
109✔
326
        then
327
                LogEnter 'Details:\n'
66✔
328
                "$detail_func"
66✔
329
                LogLeave ''
66✔
330
        fi
331

332
        return 0
109✔
333
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc