aboutsummaryrefslogtreecommitdiff
path: root/tests/functional
diff options
context:
space:
mode:
authorNikodem Rabuliński <nikodem@rabulinski.com>2024-05-06 18:13:15 +0200
committerNikodem Rabuliński <nikodem@rabulinski.com>2024-05-06 18:56:40 +0200
commit83a2cd0c469f02a7d5f8f8f903429702f0059f56 (patch)
tree6818eb746e9b15b2988c732df989fad924fb6e3a /tests/functional
parent106b95904304e498cc6c72aace705441768ab240 (diff)
Fix failing darwin tests
Some tests were failing on darwin, if the auto-allocate-uids featrure was enabled. This was because AAU on darwin works by setuid-ing as a non-existent user, so the tests that were relying on `whoami` were failing. In the case of trusted-users we fall back to printing the user id, which is already handled gracefully in the daemon code - i.e. when a user does not exist or for some other reason looking up their username is not possible, the daemon falls back to searching for their uid inside the trusted-users list. When whoami is used to print the username for other purpose, we default to printing nixbld. Change-Id: Ib61615677565098cb5fbf5e26a946ef427c58caf
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/bash-profile.sh2
-rwxr-xr-xtests/functional/init.sh2
2 files changed, 2 insertions, 2 deletions
diff --git a/tests/functional/bash-profile.sh b/tests/functional/bash-profile.sh
index 3faeaaba1..01e869202 100644
--- a/tests/functional/bash-profile.sh
+++ b/tests/functional/bash-profile.sh
@@ -2,7 +2,7 @@ source common.sh
sed -e "s|@localstatedir@|$TEST_ROOT/profile-var|g" -e "s|@coreutils@|$coreutils|g" < ../../scripts/nix-profile.sh.in > $TEST_ROOT/nix-profile.sh
-user=$(whoami)
+user=$(whoami || echo -n nixbld)
rm -rf $TEST_HOME $TEST_ROOT/profile-var
mkdir -p $TEST_HOME
USER=$user $SHELL -e -c ". $TEST_ROOT/nix-profile.sh; set"
diff --git a/tests/functional/init.sh b/tests/functional/init.sh
index f5a04f62e..663d04721 100755
--- a/tests/functional/init.sh
+++ b/tests/functional/init.sh
@@ -28,7 +28,7 @@ substituters =
flake-registry = $TEST_ROOT/registry.json
show-trace = true
include nix.conf.extra
-trusted-users = $(whoami)
+trusted-users = $(whoami || id -u)
EOF
cat > "$NIX_CONF_DIR"/nix.conf.extra <<EOF