mirror of
https://github.com/NixOS/nix
synced 2025-07-09 12:03:55 +02:00
Cleanup test skipping
- Try not to put cryptic "99" in many places Factor out `exit 99` into `skipTest` function - Alows make sure skipping a test is done with a reason `skipTest` takes a mandatory argument - Separate pure conditionals vs side-effectful test skipping. "require daemon" already had this, but "sandbox support" did not.
This commit is contained in:
parent
7f46ebcf90
commit
bfb9eb87fe
15 changed files with 33 additions and 49 deletions
|
@ -152,21 +152,29 @@ isDaemonNewer () {
|
|||
[[ $(nix eval --expr "builtins.compareVersions ''$daemonVersion'' ''$requiredVersion''") -ge 0 ]]
|
||||
}
|
||||
|
||||
skipTest () {
|
||||
echo "$1, skipping this test..." >&2
|
||||
exit 99
|
||||
}
|
||||
|
||||
requireDaemonNewerThan () {
|
||||
isDaemonNewer "$1" || exit 99
|
||||
isDaemonNewer "$1" || skipTest "Daemon is too old"
|
||||
}
|
||||
|
||||
canUseSandbox() {
|
||||
if [[ ! ${_canUseSandbox-} ]]; then
|
||||
echo "Sandboxing not supported, skipping this test..."
|
||||
return 1
|
||||
fi
|
||||
[[ ${_canUseSandbox-} ]]
|
||||
}
|
||||
|
||||
return 0
|
||||
requireSandboxSupport () {
|
||||
canUseSandbox || skipTest "Sandboxing not supported"
|
||||
}
|
||||
|
||||
requireGit() {
|
||||
[[ $(type -p git) ]] || skipTest "Git not installed"
|
||||
}
|
||||
|
||||
fail() {
|
||||
echo "$1"
|
||||
echo "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -209,8 +217,7 @@ expectStderr() {
|
|||
|
||||
needLocalStore() {
|
||||
if [[ "$NIX_REMOTE" == "daemon" ]]; then
|
||||
echo "Can’t run through the daemon ($1), skipping this test..."
|
||||
return 99
|
||||
skipTest "Can’t run through the daemon ($1)"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue