Merge pull request #8057 from obsidiansystems/slight-test-cleanup

Cleanup	test skipping
This commit is contained in:
John Ericson 2023-03-16 19:13:03 -04:00 committed by GitHub
commit acd707acca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 33 additions and 49 deletions

View file

@ -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

View file

@ -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 "Cant run through the daemon ($1), skipping this test..."
return 99
skipTest "Cant run through the daemon ($1)"
fi
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -4,7 +4,7 @@ case $system in
*linux*)
;;
*)
exit 99;
skipTest "Not running Linux";
esac
set -m # enable job control, needed for kill

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -4,7 +4,7 @@
source common.sh
if isDaemonNewer "2.4pre20211005"; then
exit 99
skipTest "Daemon is too new"
fi