mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +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
|
@ -1,5 +1,5 @@
|
|||
if ! canUseSandbox; then exit 99; fi
|
||||
if ! [[ $busybox =~ busybox ]]; then exit 99; fi
|
||||
requireSandboxSupport
|
||||
[[ $busybox =~ busybox ]] || skipTest "no busybox"
|
||||
|
||||
unset NIX_STORE_DIR
|
||||
unset NIX_STATE_DIR
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
# Test that we can successfully migrate from an older db schema
|
||||
|
||||
source common.sh
|
||||
|
||||
# Only run this if we have an older Nix available
|
||||
# XXX: This assumes that the `daemon` package is older than the `client` one
|
||||
if [[ -z "${NIX_DAEMON_PACKAGE-}" ]]; then
|
||||
exit 99
|
||||
skipTest "not using the Nix daemon"
|
||||
fi
|
||||
|
||||
source common.sh
|
||||
|
||||
killDaemon
|
||||
|
||||
# Fill the db using the older Nix
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
source common.sh
|
||||
|
||||
if [[ -z $(type -p git) ]]; then
|
||||
echo "Git not installed; skipping Git tests"
|
||||
exit 99
|
||||
fi
|
||||
requireGit
|
||||
|
||||
clearStore
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
source common.sh
|
||||
|
||||
if [[ -z $(type -p git) ]]; then
|
||||
echo "Git not installed; skipping Git tests"
|
||||
exit 99
|
||||
fi
|
||||
requireGit
|
||||
|
||||
clearStore
|
||||
|
||||
|
|
|
@ -2,10 +2,7 @@ source common.sh
|
|||
|
||||
set -u
|
||||
|
||||
if [[ -z $(type -p git) ]]; then
|
||||
echo "Git not installed; skipping Git submodule tests"
|
||||
exit 99
|
||||
fi
|
||||
requireGit
|
||||
|
||||
clearStore
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
source common.sh
|
||||
|
||||
if [[ -z $(type -p hg) ]]; then
|
||||
echo "Mercurial not installed; skipping Mercurial tests"
|
||||
exit 99
|
||||
fi
|
||||
[[ $(type -p hq) ]] || skipTest "Mercurial not installed"
|
||||
|
||||
clearStore
|
||||
|
||||
|
|
|
@ -2,13 +2,6 @@ source ../common.sh
|
|||
|
||||
registry=$TEST_ROOT/registry.json
|
||||
|
||||
requireGit() {
|
||||
if [[ -z $(type -p git) ]]; then
|
||||
echo "Git not installed; skipping flake tests"
|
||||
exit 99
|
||||
fi
|
||||
}
|
||||
|
||||
writeSimpleFlake() {
|
||||
local flakeDir="$1"
|
||||
cat > $flakeDir/flake.nix <<EOF
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
source ./common.sh
|
||||
|
||||
if [[ -z $(type -p hg) ]]; then
|
||||
echo "Mercurial not installed; skipping"
|
||||
exit 99
|
||||
fi
|
||||
[[ $(type -p hq) ]] || skipTest "Mercurial not installed"
|
||||
|
||||
flake1Dir=$TEST_ROOT/flake-hg1
|
||||
mkdir -p $flake1Dir
|
||||
|
|
|
@ -4,7 +4,7 @@ case $system in
|
|||
*linux*)
|
||||
;;
|
||||
*)
|
||||
exit 99;
|
||||
skipTest "Not running Linux";
|
||||
esac
|
||||
|
||||
set -m # enable job control, needed for kill
|
||||
|
|
|
@ -4,13 +4,13 @@ needLocalStore "the sandbox only runs on the builder side, so it makes no sense
|
|||
|
||||
clearStore
|
||||
|
||||
if ! canUseSandbox; then exit 99; fi
|
||||
requireSandboxSupport
|
||||
|
||||
# Note: we need to bind-mount $SHELL into the chroot. Currently we
|
||||
# only support the case where $SHELL is in the Nix store, because
|
||||
# otherwise things get complicated (e.g. if it's in /bin, do we need
|
||||
# /lib as well?).
|
||||
if [[ ! $SHELL =~ /nix/store ]]; then exit 99; fi
|
||||
if [[ ! $SHELL =~ /nix/store ]]; then skipTest "Shell is not from Nix store"; fi
|
||||
|
||||
chmod -R u+w $TEST_ROOT/store0 || true
|
||||
rm -rf $TEST_ROOT/store0
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
source common.sh
|
||||
|
||||
if [[ $BUILD_SHARED_LIBS != 1 ]]; then
|
||||
echo "plugins are not supported"
|
||||
exit 99
|
||||
skipTest "Plugins are not supported"
|
||||
fi
|
||||
|
||||
res=$(nix --option setting-set true --option plugin-files $PWD/plugins/libplugintest* eval --expr builtins.anotherNull)
|
||||
|
|
|
@ -4,7 +4,7 @@ sed -i 's/experimental-features .*/& recursive-nix/' "$NIX_CONF_DIR"/nix.conf
|
|||
restartDaemon
|
||||
|
||||
# FIXME
|
||||
if [[ $(uname) != Linux ]]; then exit 99; fi
|
||||
if [[ $(uname) != Linux ]]; then skipTest "Not running Linux"; fi
|
||||
|
||||
clearStore
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ nix shell -f shell-hello.nix hello -c hello NixOS | grep 'Hello NixOS'
|
|||
nix shell -f shell-hello.nix hello^dev -c hello2 | grep 'Hello2'
|
||||
nix shell -f shell-hello.nix 'hello^*' -c hello2 | grep 'Hello2'
|
||||
|
||||
if ! canUseSandbox; then exit 99; fi
|
||||
requireSandboxSupport
|
||||
|
||||
chmod -R u+w $TEST_ROOT/store0 || true
|
||||
rm -rf $TEST_ROOT/store0
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
source common.sh
|
||||
|
||||
if isDaemonNewer "2.4pre20211005"; then
|
||||
exit 99
|
||||
skipTest "Daemon is too new"
|
||||
fi
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue