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

CyberShadow / aconfmgr / 660

22 Dec 2025 03:28PM UTC coverage: 79.739% (-14.0%) from 93.708%
660

Pull #231

github

CyberShadow-Renovate
Update dependency Arch Linux Base to v2025.12.01
Pull Request #231: Update dependency Arch Linux Base to v2025.12.01

3239 of 4062 relevant lines covered (79.74%)

293.61 hits per line

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

49.17
/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
17✔
20
                LogLeave 'Skipping (integration-only test).\n'
17✔
21
                printf '\n' 1>&2 # Leave a blank line between tests
17✔
22
                Exit 0
17✔
23
        fi
24
}
25

26
function TestNeedRoot() {
27
        TestIntegrationOnly
1✔
28

29
        if [[ "$EUID" != 0 ]]
×
30
        then
31
                Log 'Re-executing as root ...\n'
×
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
14✔
40
        TestInitAUR
×
41
}
42

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

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

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

57
function TestPhase_Check() {
58
        LogLeave
72✔
59
        LogEnter 'Checking results...\n'
71✔
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
        aura_opts
×
157

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

170
declare -i test_expected_warnings=0
90✔
171

172
function TestDone() {
173
        LogLeave
73✔
174

175
        # Final checks
176

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

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

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

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

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

218
###############################################################################
219
# Files
220

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

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

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

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

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

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

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

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

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

273
        TestAddFSObj "$package" "$path" file "$contents" "$mode" "$owner" "$group" "$mtime"
149✔
274
}
275

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

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

287
###############################################################################
288
# Packages
289

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

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

300

301
###############################################################################
302
# Configuration
303

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

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

319
###############################################################################
320
# Test suite overrides
321

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

326
        if [[ -n "$detail_func" ]]
99✔
327
        then
328
                LogEnter 'Details:\n'
58✔
329
                "$detail_func"
57✔
330
                LogLeave ''
58✔
331
        fi
332

333
        return 0
99✔
334
}
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

© 2026 Coveralls, Inc