update: a failing hook without run_update fails the update
shellcheck / shellcheck (push) Failing after 17s
shellcheck / shellcheck (push) Failing after 17s
Since a65f07c ran each hook in a subshell, a hook that does its work as
it's sourced (12-migrations, 15-services, 20-aur, 30-flatpak and others)
had its failure lost: the run_update check after source left the
subshell's status at 0, so update said "Done." and exited 0. The smoketest's
40-failing-migration caught it. update now exits the subshell with the
sourced hook's status.
Also, the smoketest scenarios that check whether a migration ran look for
"Running migration " so install.sh's "Running migrations..." heading
doesn't match (11-refresh failed on it).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,12 @@ hook() {
|
||||
printf '#!/bin/bash\nrun_update() {\n%s\n}\n' "$2" > "$CD/updates.d/$1.sh"
|
||||
}
|
||||
|
||||
# plain_hook NAME BODY: a hook that does its work as it's sourced, with no
|
||||
# run_update, like updates.d/12-migrations.sh
|
||||
plain_hook() {
|
||||
printf '#!/bin/bash\n%s\n' "$2" > "$CD/updates.d/$1.sh"
|
||||
}
|
||||
|
||||
ran() {
|
||||
[ "$(cat "$RAN" 2> /dev/null)" = "$(printf '%s\n' "$@")" ]
|
||||
}
|
||||
@@ -70,6 +76,25 @@ ran() {
|
||||
ran a b c
|
||||
}
|
||||
|
||||
@test "a failing hook without run_update fails the update too" {
|
||||
plain_hook 10-a 'echo a >> "$RAN"; false'
|
||||
plain_hook 20-b 'echo b >> "$RAN"'
|
||||
|
||||
run "$CD/update"
|
||||
[ "$status" -eq 1 ]
|
||||
[[ "$output" == *"Done, with errors in: 10-a.sh"* ]]
|
||||
ran a b
|
||||
}
|
||||
|
||||
@test "a hook without run_update that succeeds doesn't fail the update" {
|
||||
plain_hook 10-a 'echo a >> "$RAN"'
|
||||
|
||||
run "$CD/update"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"Done."* ]]
|
||||
ran a
|
||||
}
|
||||
|
||||
@test "a hook that exits doesn't end the update" {
|
||||
hook 10-a 'echo a >> "$RAN"; exit 0'
|
||||
hook 20-b 'echo b >> "$RAN"'
|
||||
|
||||
Reference in New Issue
Block a user