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

CyberShadow / aconfmgr / 662

22 Dec 2025 03:28PM UTC coverage: 91.427% (-2.3%) from 93.708%
662

Pull #232

github

CyberShadow-Renovate
Update dependency aura to v20251216074710
Pull Request #232: Update dependency aura to v20251216074710

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

124 existing lines in 16 files now uncovered.

4586 of 5016 relevant lines covered (91.43%)

407.42 hits per line

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

95.46
/test/t/lib-funcs-integ.bash
1
# Test case configuration functions (integration tests)
2

3
###############################################################################
4
# Initialization
5

6
function TestInit() {
7
        # No TTY for confirmations
8
        pacman_opts+=(--noconfirm)
44✔
9
        makepkg_opts+=(--noconfirm)
44✔
10

11
        pacaur_opts+=(--noconfirm --noedit)
44✔
12
        aurman_opts+=(--noconfirm --noedit --skip_news)
44✔
13
        yaourt_opts+=(--noconfirm)
44✔
14
        yay_opts+=(--noconfirm)
44✔
15
        paru_opts+=(--noconfirm)
44✔
16
        aura_opts+=(--noconfirm)
44✔
17

18
        # Improve CI reliability when downloading from archive.archlinux.org
19
        pacman_opts+=(--disable-download-timeout)
44✔
20

21
        # pacaur insists that this is set, even if it will never invoke it
22
        export EDITOR=/bin/cat
88✔
23

24
        # Allows AUR helpers find perl tools etc.
25
        # shellcheck disable=SC2016
26
        PATH=$(env -i sh -c 'source /etc/profile 1>&2 ; printf -- %s "$PATH"')
88✔
27

28
        # Configuration matching the Docker image
29
        cat > "$config_dir"/10-system.sh <<'EOF'
44✔
30
AddPackage arch-install-scripts
44✔
31
AddPackage base
44✔
32
AddPackage base-devel
44✔
33

44✔
34
AddPackage ruby-rdoc
44✔
35
AddPackage rubygems
44✔
36

44✔
37
AddPackage git
44✔
38
AddPackage pacutils
44✔
39
AddPackage expect
44✔
40

44✔
41
AddPackage aur
44✔
42
IgnorePackage --foreign parent-package
44✔
43

44✔
44
IgnorePath /README
44✔
45
IgnorePath /version
44✔
46
IgnorePath /pkglist.x86_64.txt
44✔
47

44✔
48
IgnorePath /.dockerenv
44✔
49
IgnorePath /aconfmgr/\*
44✔
50
IgnorePath /aconfmgr-packages/\*
44✔
51
IgnorePath /aconfmgr-repo/\*
44✔
52
IgnorePath /opt/aur
44✔
53

44✔
54
IgnorePath /etc/\*
44✔
55
IgnorePath /usr/\*
44✔
56
IgnorePath /srv/\*
44✔
57
IgnorePath /var/\*
44✔
58
EOF
44✔
59

44✔
60
        # Container root directory permissions vary by runtime (Docker vs Podman)
44✔
61
        # Docker: / has mode 755 (default), Podman: / has mode 555 (non-default)
44✔
62
        # Only set if mode differs from aconfmgr's default (755 for directories)
44✔
63
        local root_mode
44✔
64
        root_mode=$(stat -c %a /)
88✔
65
        if [[ "$root_mode" != "755" ]]
44✔
66
        then
44✔
67
                printf '# Root directory has non-default mode\nSetFileProperty / mode %s\n' "$root_mode" >> "$config_dir"/10-system.sh
44✔
68
        fi
44✔
69

44✔
70
        test_fs_root=/
44✔
71
}
44✔
72

44✔
73
function TestPhase_RunHook() {
44✔
74
        if [[ "${#test_adopted_packages[@]}" -gt 0 ]]
44✔
75
        then
44✔
76
                TestCreateParentPackage
44✔
77
        fi
44✔
78

44✔
79
        command sudo rm -f /var/log/pacman.log
44✔
80
}
44✔
81

44✔
82
###############################################################################
44✔
83
# Files
44✔
84

44✔
85
function TestAddFSObj() {
44✔
86
        local package=$1 # empty string to add to filesystem
310✔
87
        local path=$2
310✔
88
        local type=$3 # file, dir, link
310✔
89
        local contents=$4 # file contents or link data
310✔
90
        local mode=${5:-}
310✔
91
        local owner=${6:-}
310✔
92
        local group=${7:-}
310✔
93
        local mtime=${8:-@0}
310✔
94

44✔
95
        local root prefix
310✔
96
        if [[ -z "$package" ]]
310✔
97
        then
44✔
98
                root=
61✔
99
                prefix=(command sudo)
61✔
100
        else
44✔
101
                root="$test_data_dir"/package-files/"$package"/files
291✔
102
                mkdir -p "$root"
291✔
103
                prefix=()
291✔
104
        fi
44✔
105
        local fn="$root"/"$path"
310✔
106

44✔
107
        case "$type" in
606✔
108
                file)
44✔
109
                        "${prefix[@]}" mkdir -p "$(dirname "$fn")"
605✔
110
                        printf -- "%s" "$contents" | "${prefix[@]}" sh -c "$(printf 'cat > %q' "$fn")"
900✔
111
                        ;;
44✔
112
                dir)
44✔
113
                        test -z "$contents" || FatalError 'Attempting to create directory with non-empty contents\n'
44✔
114
                        "${prefix[@]}" mkdir -p "$fn"
44✔
115
                        ;;
44✔
116
                link)
44✔
117
                        "${prefix[@]}" mkdir -p "$(dirname "$fn")"
45✔
118
                        "${prefix[@]}" ln -s "$contents" "$fn"
44✔
119
                        ;;
44✔
120
                *)
44✔
121
                        FatalError 'Unknown filesystem object type %s\n' "$type"
44✔
122
                        ;;
44✔
123
        esac
44✔
124
        "${prefix[@]}" touch --no-dereference --date "$mtime" "$fn"
310✔
125

44✔
126
        if [[ -n "$mode"  ]] ; then "${prefix[@]}" chmod "$mode"  "$fn" ; fi
316✔
127

44✔
128
        if [[ -z "$package" ]]
310✔
129
        then
44✔
130
                if [[ -n "$owner" ]] ; then "${prefix[@]}" chown --no-dereference "$owner" "$fn" ; fi
63✔
131
                if [[ -n "$group" ]] ; then "${prefix[@]}" chgrp --no-dereference "$group" "$fn" ; fi
63✔
132
        else
44✔
133
                tar rf "$test_data_dir"/package-files/"$package"/files.tar \
291✔
134
                        -C "$root" \
44✔
135
                        --owner="${owner:-root}" \
44✔
136
                        --group="${group:-root}" \
44✔
137
                        ./"$path"
44✔
138
                rm -rf "$root"
291✔
139
        fi
44✔
140
}
44✔
141

44✔
142
function TestDeleteFile() {
44✔
143
        local path=$1
44✔
144

44✔
145
        command sudo rm -rf "$path"
44✔
146
}
44✔
147

44✔
148
###############################################################################
44✔
149
# Packages
44✔
150

44✔
151
# Helper
44✔
152
function TestMakePkg() {
44✔
153
        local dir=$1
433✔
154
        shift
433✔
155

44✔
156
        local args=(makepkg --nodeps "$@")
844✔
157

44✔
158
        rm -rf /tmp/aconfmgr-build
433✔
159
        cp -a "$dir" /tmp/aconfmgr-build
433✔
160

44✔
161
        {
44✔
162
                cat /etc/makepkg.conf
433✔
163
                cat <<-'EOF'
433✔
164
                        PKGEXT='.pkg.tar.zst'
44✔
165
                        COMPRESSZST=(zstd -c -T0 -18 -)
44✔
166
                EOF
44✔
167
        } > /tmp/aconfmgr-build/makepkg.conf
44✔
168
        args+=(--config /tmp/aconfmgr-build/makepkg.conf)
433✔
169

44✔
170
        local timestamp=0
433✔
171
        if [[ -f "$dir"/time ]]
433✔
172
        then
44✔
173
                timestamp=$(stat --format=%Y "$dir"/time)
44✔
174
        fi
44✔
175

44✔
176
        if [[ "$EUID" -eq 0 ]]
433✔
177
        then
44✔
178
                chown -R nobody: /tmp/aconfmgr-build
44✔
179
                env -i -C /tmp/aconfmgr-build SOURCE_DATE_EPOCH="$timestamp" setpriv --reuid=nobody --regid=nobody --clear-groups "${args[@]}"
44✔
180
        else
44✔
181
                env -i -C /tmp/aconfmgr-build SOURCE_DATE_EPOCH="$timestamp" "${args[@]}"
433✔
182
        fi
44✔
183
}
44✔
184

44✔
185
function TestCreatePackage() {
44✔
186
        local package=$1
297✔
187
        local kind=$2
297✔
188
        local pkgver=1.0
297✔
189
        local pkgrel=1
297✔
190
        local arch=x86_64
297✔
191
        local groups=()
572✔
192
        local depends=()
572✔
193
        local provides=()
572✔
194
        local time=@0
297✔
195
        local pkgbuild
297✔
196
        local pkg_fn="$package"-"$pkgver"-"$pkgrel"-"$arch".pkg.tar.zst
297✔
197

44✔
198
        shift 2
297✔
199
        local arg
297✔
200
        for arg in "$@"
45✔
201
        do
44✔
202
                eval "$arg"
48✔
203
        done
44✔
204

44✔
205
        local dir="$test_data_dir"/packages/"$kind"/"$package"
297✔
206
        mkdir -p "$dir"
297✔
207
        touch --date "$time" "$dir"/time
297✔
208

44✔
209
        mkdir "$dir"/build
297✔
210

44✔
211
        local tar="$test_data_dir"/package-files/"$package"/files.tar
297✔
212
        if [[ -f "$tar" ]]
297✔
213
        then
44✔
214
                cp "$tar" "$dir"/build/
291✔
215
        fi
44✔
216

44✔
217
        # shellcheck disable=SC2059
44✔
218
        (
44✔
219
                if [[ -v pkgbuild ]]
297✔
220
                then
44✔
221
                        printf -- %s "$pkgbuild"
44✔
222
                else
44✔
223
                        cat <<EOF
1,122✔
224
pkgname=$package
44✔
225
pkgver=$pkgver
44✔
226
pkgrel=$pkgrel
44✔
227
pkgdesc="Dummy aconfmgr test suite package: subtitle"
44✔
228
arch=($arch)
44✔
229
groups=($(PrintQArray groups))
44✔
230
depends=($(PrintQArray depends))
44✔
231
provides=($(PrintQArray provides))
44✔
232
EOF
44✔
233

44✔
234
                        if [[ -f "$tar" ]]
297✔
235
                        then
44✔
236
                                cat <<'EOF'
291✔
237
source=(files.tar)
44✔
238
md5sums=(SKIP)
44✔
239

44✔
240
package() {
44✔
241
        tar xf "$srcdir"/files.tar -C "$pkgdir"
44✔
242
}
44✔
243
EOF
44✔
244
                        fi
44✔
245
                fi
44✔
246
        ) > "$dir"/build/PKGBUILD
44✔
247

44✔
248
        TestMakePkg "$dir"/build
297✔
249

44✔
250
        local pkg_path=/tmp/aconfmgr-build/"$pkg_fn"
297✔
251
        test -f "$pkg_path" || FatalError 'Package expected to exist: %q\n' "$pkg_path"
297✔
252
        cp "$pkg_path" "$dir"/
297✔
253
        ln -s "$pkg_fn" "$dir"/pkg
297✔
254

44✔
255
        if [[ "$kind" == native ]]
297✔
256
        then
44✔
257
                command sudo repo-add /aconfmgr-repo/aconfmgr.db.tar "$pkg_path"
167✔
258
                command sudo cp "$pkg_path" /aconfmgr-repo/
167✔
259
                command sudo pacman -Sy
167✔
260
        fi
44✔
261

44✔
262
        if [[ "$kind" == foreign && -f ~/aur-initialized ]]
432✔
263
        then
44✔
264
                (
44✔
265
                        cd "$dir"/build
167✔
266

44✔
267
                        TestMakePkg . --printsrcinfo > .SRCINFO
167✔
268

44✔
269
                        git init .
167✔
270
                        git add PKGBUILD .SRCINFO
167✔
271
                        if [[ -f files.tar ]]
167✔
272
                        then
44✔
273
                                git add files.tar
166✔
274
                        fi
44✔
275
                        git commit -m 'Initial commit'
167✔
276
                        git push aur@aur.archlinux.org:"$package".git master
167✔
277
                )
44✔
278
        fi
44✔
279

44✔
280
        rm -rf "$test_data_dir"/package-files/"$package"
297✔
281
}
44✔
282

44✔
283
# Delete an installable package.
44✔
284
function TestDeletePackage() {
44✔
285
        local package=$1
166✔
286
        local kind=$2
166✔
287

44✔
288
        local dir="$test_data_dir"/packages/"$kind"/"$package"
166✔
289
        test -d "$dir"
166✔
290
        rm -rf "$dir"
166✔
291

44✔
292
        if [[ "$kind" == native ]]
166✔
293
        then
44✔
294
                command sudo find /aconfmgr-repo/ -name "$package"'-*.pkg.tar.*' -delete
104✔
295
                command sudo repo-remove /aconfmgr-repo/aconfmgr.db.tar "$package"
104✔
296
                command sudo pacman -Sy
104✔
297
        fi
44✔
298

44✔
299
        if [[ "$kind" == foreign && -f ~/aur-initialized ]]
228✔
300
        then
44✔
301
                Log 'TOOO: delete packages from AUR\n'
104✔
302
        fi
44✔
303
}
44✔
304

44✔
305
# Create dummy parent package to distinguish dependency from orphan packages.
44✔
306
function TestCreateParentPackage() {
44✔
307
        local dir="$test_data_dir"/parent-package
44✔
308
        mkdir "$dir"
44✔
309

44✔
310
        # shellcheck disable=SC2059
44✔
311
        printf "$(cat <<EOF
50✔
312
pkgname=parent-package
44✔
313
pkgver=1.0
44✔
314
pkgrel=1
44✔
315
pkgdesc="Dummy aconfmgr test suite parent package"
44✔
316
depends=(%s)
44✔
317
arch=(any)
44✔
318

44✔
319
EOF
44✔
320
)" "$(printf '%q ' "${test_adopted_packages[@]}")" > "$dir"/PKGBUILD
44✔
321

44✔
322
        TestMakePkg "$dir"
44✔
323

44✔
324
        command sudo pacman -U --noconfirm /tmp/aconfmgr-build/parent-package-1.0-1-any.pkg.tar.*
44✔
325
}
44✔
326

44✔
327
# Packages to give a parent to,
44✔
328
# so that they're not considered orphaned.
44✔
329
test_adopted_packages=()
44✔
330

44✔
331
function TestInstallPackage() {
44✔
332
        local package=$1
141✔
333
        local kind=$2
141✔
334
        local inst_as=$3
141✔
335

44✔
336
        local dir="$test_data_dir"/packages/"$kind"/"$package"
141✔
337

44✔
338
        local args=(command sudo pacman --noconfirm)
250✔
339
        case "$inst_as" in
141✔
340
                explicit)
44✔
341
                        args+=(--asexplicit)
75✔
342
                        ;;
44✔
343
                dependency)
44✔
344
                        args+=(--asdeps)
75✔
345
                        test_adopted_packages+=("$package")
75✔
346
                        ;;
44✔
347
                orphan)
44✔
348
                        args+=(--asdeps)
74✔
349
                        ;;
44✔
350
                *)
44✔
351
                        FatalError "Unknown inst_as parameter: %s\n" "$inst_as"
44✔
352
        esac
44✔
353

44✔
354
        if [[ "$kind" == native ]]
141✔
355
        then
44✔
356
                "${args[@]}" -S "$package"
91✔
357
        else
44✔
358
                "${args[@]}" -U "$dir"/"$(readlink "$dir"/pkg)"
141✔
359
        fi
44✔
360

44✔
361
}
44✔
362

44✔
363
function TestExpectPacManLog() {
44✔
364
        command sudo touch /var/log/pacman.log
44✔
365
        diff -u /dev/stdin <( sed -n 's/^.*\[PACMAN\] Running '\''pacman \(--noconfirm \)\?\(--disable-download-timeout \)\?\(.*\)'\''$/\3/p' /var/log/pacman.log )
46✔
366
}
44✔
367

44✔
368
###############################################################################
44✔
369
# AUR
44✔
370

44✔
371
function TestInitAUR() {
44✔
372
        test ! -f ~/aur-initialized || return 0
44✔
373

44✔
374
        LogEnter 'Initializing AUR support...\n'
44✔
375

44✔
376
        if [[ ! -v ACONFMGR_IN_CONTAINER ]]
44✔
377
        then
44✔
378
                FatalError 'Refusing to start outside Docker.\n'
44✔
379
        fi
44✔
380

44✔
381
        LogEnter 'Starting AUR...\n'
44✔
382
        command sudo env ACONFMGR_IN_CONTAINER=1 /opt/aur/start.sh
44✔
383
        LogLeave
44✔
384

44✔
385
        LogEnter 'Generating a SSH key...\n'
44✔
386
        mkdir -p ~/.ssh
44✔
387
        chmod 700 ~/.ssh
44✔
388
        ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519
44✔
389
        LogLeave
44✔
390

44✔
391
        LogEnter 'Creating AUR user directly in database...\n'
44✔
392
        # Python 3.13/FastAPI form handling breaks the registration endpoint
44✔
393
        # Bypass it by creating the user directly in the database
44✔
394
        local ssh_pubkey
44✔
395
        # Extract just keytype and keytext (no comment) to match what SSH passes to aurweb-git-auth
44✔
396
        ssh_pubkey=$(awk '{print $1 " " $2}' ~/.ssh/id_ed25519.pub)
54✔
397
        local ssh_fingerprint
44✔
398
        # Strip "SHA256:" prefix - Fingerprint column is varchar(44)
44✔
399
        ssh_fingerprint=$(ssh-keygen -lf ~/.ssh/id_ed25519.pub | awk '{print $2}' | sed 's/^SHA256://')
74✔
400

44✔
401
        command sudo -u aur mysql --socket=/opt/aur/run/mysqld.sock AUR <<-EOF
44✔
402
                INSERT INTO Users (
44✔
403
                        AccountTypeID, Username, Email, Passwd, Salt, ResetKey,
44✔
404
                        RealName, LangPreference, Timezone, Suspended
44✔
405
                ) VALUES (
44✔
406
                        1, 'aconfmgr', 'aconfmgr@thecybershadow.net', '', '', 'ResetKeyPlaceholder',
44✔
407
                        '', 'en', 'UTC', 0
44✔
408
                );
44✔
409

44✔
410
                SET @user_id = LAST_INSERT_ID();
44✔
411

44✔
412
                INSERT INTO SSHPubKeys (UserID, Fingerprint, PubKey)
44✔
413
                VALUES (@user_id, '$ssh_fingerprint', '$ssh_pubkey');
44✔
414
        EOF
44✔
415
        LogLeave
44✔
416

44✔
417
        LogEnter 'Activating account (clearing ResetKey and setting password)...\n'
44✔
418
        # Generate a bcrypt password hash for "testpass" using aurweb's virtualenv Python
44✔
419
        password_hash=$(command sudo -u aur bash -c 'cd /opt/aur/aurweb && poetry run python -c "import bcrypt; print(bcrypt.hashpw(b\"testpass\", bcrypt.gensalt()).decode(\"utf-8\"))"')
54✔
420
        echo "Generated password hash: $password_hash"
44✔
421
        command sudo -u aur mysql --socket=/opt/aur/run/mysqld.sock AUR -e "UPDATE Users SET ResetKey = '', Passwd = '$password_hash' WHERE Username = 'aconfmgr'"
44✔
422
        unset password_hash
44✔
423
        LogLeave
44✔
424

44✔
425
        LogEnter 'Verifying account activation...\n'
44✔
426
        command sudo -u aur mysql --socket=/opt/aur/run/mysqld.sock AUR -e "SELECT ID, Username, ResetKey FROM Users WHERE Username = 'aconfmgr'"
44✔
427
        command sudo -u aur mysql --socket=/opt/aur/run/mysqld.sock AUR -e "SELECT UserID, Fingerprint, PubKey FROM SSHPubKeys WHERE UserID = (SELECT ID FROM Users WHERE Username = 'aconfmgr')"
44✔
428
        echo "Checking if password is set..."
44✔
429
        command sudo -u aur mysql --socket=/opt/aur/run/mysqld.sock AUR -e "SELECT ID, Username, LENGTH(Passwd) as PasswdLength, Suspended FROM Users WHERE Username = 'aconfmgr'"
44✔
430
        LogLeave
44✔
431

44✔
432
        LogEnter 'Verifying aurweb-git-auth is installed...\n'
44✔
433
        ls -la /usr/bin/aurweb-git-auth || echo "aurweb-git-auth not found"
44✔
434
        echo "aurweb-git-auth wrapper installed, will be tested via SSH connection"
44✔
435
        LogLeave
44✔
436

44✔
437
        LogEnter 'Adding SSH host keys...\n'
44✔
438
        ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
44✔
439
        LogLeave
44✔
440

44✔
441
        LogEnter 'Checking SSH...\n'
44✔
442
        ssh aur@aur.archlinux.org help || {
44✔
443
                echo "SSH failed, checking debug log..."
44✔
444
                cat /tmp/aurweb-git-auth-debug.log 2>/dev/null || echo "No debug log found"
44✔
445
                return 1
44✔
446
        }
44✔
447
        LogLeave
44✔
448

44✔
449
        LogEnter 'Configuring git...\n'
44✔
450
        git config --global user.name aconfmgr
44✔
451
        git config --global user.email 'aconfmgr@thecybershadow.net'
44✔
452
        LogLeave
44✔
453

44✔
454
        # Create "$tmp_dir" now with the correct mode.
44✔
455
        mkdir --mode=700 "$tmp_dir"
44✔
456

44✔
457
        touch ~/aur-initialized
44✔
458

44✔
459
        LogLeave
44✔
460
}
44✔
461

44✔
462
# Copies a package from the real AUR to our local instance.
44✔
463
function TestNeedAURPackage() {
44✔
464
        local package=$1
45✔
465
        local commit=$2
45✔
466
        shift 2
45✔
467
        local pkgbuild_extras=("$@")
51✔
468

44✔
469
        function TestEditHosts() {
44✔
470
                local transform=$1
51✔
471

44✔
472
                # Docker bind-mounts /etc/hosts; sed -i doesn't work
44✔
473
                local hosts
51✔
474
                hosts=$(cat /etc/hosts)
63✔
475
                printf -- %s "$hosts" | sed "$transform" | command sudo tee /etc/hosts > /dev/null
75✔
476
        }
44✔
477

44✔
478
        LogEnter 'Copying package %s from AUR...\n' "$(Color M "%q" "$package")"
51✔
479

44✔
480
        local dir="$test_aur_dir"/"$package"
45✔
481

44✔
482
        LogEnter 'Downloading package...\n'
45✔
483
        TestEditHosts 's/^.*aur.archlinux.org$/#\0/'
45✔
484
        mkdir -p "$(dirname "$dir")"
51✔
485
        git clone https://aur.archlinux.org/"$package".git "$dir"
45✔
486
        git -C "$dir" reset --hard "$commit"
45✔
487
        LogLeave
45✔
488

44✔
489
        if [[ "${#pkgbuild_extras[@]}" -gt 0 ]]
45✔
490
        then
44✔
491
                LogEnter 'Patching PKGBUILD...\n'
44✔
492
                test -f "$dir"/PKGBUILD
44✔
493
                printf '\n' >> "$dir"/PKGBUILD
44✔
494
                local line
44✔
495
                for line in "${pkgbuild_extras[@]}"
44✔
496
                do
44✔
497
                        printf '%s\n' "$line" >> "$dir"/PKGBUILD
44✔
498
                done
44✔
499
                git -C "$dir" commit -am 'Patch PKGBUILD for aconfmgr test suite'
44✔
500
                LogLeave
44✔
501
        fi
44✔
502

44✔
503
        LogEnter 'Uploading package...\n'
45✔
504
        TestEditHosts 's/^#\(.*aur.archlinux.org\)$/\1/'
45✔
505
        git -C "$dir" push aur@aur.archlinux.org:"$package".git master
45✔
506
        LogLeave
45✔
507

44✔
508
        LogLeave
45✔
509
}
44✔
510

44✔
511
function TestNeedPacaur() {
44✔
512
        TestNeedAURPackage pacaur 806775d8f6f87626501f15988e69b28329d2af8d
44✔
513
}
44✔
514

44✔
515
function TestNeedAuracle() {
44✔
516
        # shellcheck disable=SC2016,SC1004
44✔
517
        TestNeedAURPackage auracle-git 6649f56149557522787270ea55cb4f20827cae70 "$(cat <<-'EOF'
46✔
518
                source[0]="${source[0]/%/#commit=825327277c070f601ef613ffc76130a45a3a28a6}"
44✔
519
                check() { :; }
44✔
520
                EOF
44✔
521
)"
×
522
}
523

524
# Upload a new version of an AUR package with the given lines to
525
# override existing declarations.
526
function TestUpdateAurPackage() {
UNCOV
527
        local package=$1
×
UNCOV
528
        local kind=foreign
×
UNCOV
529
        shift
×
530
        local lines=("$@")
531

532
        (
UNCOV
533
                cd "$test_data_dir"/packages/"$kind"/"$package"/build
×
UNCOV
534
                local line
×
UNCOV
535
                printf '%s\n' "${lines[@]}" >> PKGBUILD
×
UNCOV
536
                TestMakePkg . --printsrcinfo > .SRCINFO
×
UNCOV
537
                git add PKGBUILD .SRCINFO
×
UNCOV
538
                git commit -m 'AUR package update'
×
UNCOV
539
                git push aur@aur.archlinux.org:"$package".git master
×
540
        )
×
541
}
542

543
# Common test code for testing integration with an AUR helper.
544
function TestAURHelper() {
545
        aur_helper=$1
3✔
546
        local cache_dir=$2
3✔
547
        local can_build_only=$3
3✔
548

549
        TestPhase_Setup ###############################################################
3✔
550
        TestAddPackageFile test-package /testfile.txt 'File contents'
3✔
551
        TestCreatePackage test-package foreign
3✔
552

553
        TestPhase_Run #################################################################
3✔
554

555
        LogEnter 'Test installing a package:\n'
3✔
556
        TestAddConfig AddPackage --foreign test-package
3✔
557
        AconfApply
3✔
558
        diff -u <(cat /testfile.txt) <(printf 'File contents')
9✔
559
        test -z "$cache_dir" -o -d "$cache_dir"
3✔
560
        LogLeave 'OK\n'
3✔
561

562
        LogEnter 'Test getting a file from an installed package:\n'
3✔
563
        diff -u "$(GetPackageOriginalFile test-package /testfile.txt)" <(printf 'File contents')
9✔
564
        RemoveFile /testfile.txt
3✔
565
        LogLeave 'OK\n'
3✔
566

567
        LogEnter 'Test getting a file from a non-installed package:\n'
3✔
568
        command sudo pacman -R --noconfirm test-package
3✔
569
        diff -u "$(GetPackageOriginalFile test-package /testfile.txt)" <(printf 'File contents')
9✔
570
        RemoveFile /testfile.txt
3✔
571
        LogLeave 'OK\n'
3✔
572

573
        if "$can_build_only"
3✔
574
        then
UNCOV
575
                LogEnter 'Test getting a file from a non-installed package (clean cache):\n'
×
UNCOV
576
                test -z "$cache_dir" || rm -rf "$cache_dir"
×
UNCOV
577
                diff -u "$(GetPackageOriginalFile test-package /testfile.txt)" <(printf 'File contents')
×
UNCOV
578
                test -z "$cache_dir" -o -d "$cache_dir"
×
UNCOV
579
                RemoveFile /testfile.txt
×
UNCOV
580
                LogLeave 'OK\n'
×
581

UNCOV
582
                LogEnter 'Test getting a file from another version of the package:\n'
×
UNCOV
583
                test -z "$cache_dir" || rm -rf "$cache_dir"
×
UNCOV
584
                TestUpdateAurPackage test-package 'pkgver=2.0'
×
UNCOV
585
                diff -u "$(GetPackageOriginalFile test-package /testfile.txt)" <(printf 'File contents')
×
UNCOV
586
                test -z "$cache_dir" -o -d "$cache_dir"
×
UNCOV
587
                RemoveFile /testfile.txt
×
UNCOV
588
                LogLeave 'OK\n'
×
589
        fi
590
}
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