tests/common.sh.in: Add enableFeatures helper

This commit is contained in:
Eelco Dolstra 2022-03-02 21:48:25 +01:00
parent 5d208cbe41
commit d2586188fe
12 changed files with 13 additions and 22 deletions

View file

@ -2,7 +2,7 @@ source common.sh
file=build-hook-ca-floating.nix
sed -i 's/experimental-features .*/& ca-derivations/' "$NIX_CONF_DIR"/nix.conf
enableFeatures "ca-derivations ca-references"
CONTENT_ADDRESSED=true

View file

@ -37,7 +37,7 @@ testCutoffFor () {
}
testCutoff () {
# Don't directly build depenentCA, that way we'll make sure we dodn't rely on
# Don't directly build dependentCA, that way we'll make sure we don't rely on
# dependent derivations always being already built.
#testDerivation dependentCA
testCutoffFor transitivelyDependentCA

View file

@ -1,5 +1,5 @@
source ../common.sh
sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_DIR"/nix.conf
enableFeatures "ca-derivations ca-references"
restartDaemon

View file

@ -2,8 +2,6 @@ source ./common.sh
requireDaemonNewerThan "2.4pre20210625"
sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_DIR"/nix.conf
export REMOTE_STORE_DIR="$TEST_ROOT/remote_store"
export REMOTE_STORE="file://$REMOTE_STORE_DIR"

View file

@ -2,9 +2,6 @@
source common.sh
# Globally enable the ca derivations experimental flag
sed -i 's/experimental-features = .*/& ca-derivations ca-references/' "$NIX_CONF_DIR/nix.conf"
export REMOTE_STORE_DIR="$TEST_ROOT/remote_store"
export REMOTE_STORE="file://$REMOTE_STORE_DIR"

View file

@ -2,8 +2,6 @@
source common.sh
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
FLAKE_PATH=path:$PWD
nix run --no-write-lock-file $FLAKE_PATH#runnable

View file

@ -2,8 +2,6 @@
source common.sh
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
CONTENT_ADDRESSED=true
cd ..
source ./nix-shell.sh

View file

@ -4,8 +4,6 @@ source common.sh
requireDaemonNewerThan "2.4pre20210626"
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
export NIX_TESTS_CA_BY_DEFAULT=1
cd ..
source ./post-hook.sh

View file

@ -4,8 +4,6 @@ source common.sh
requireDaemonNewerThan "2.4pre20210623"
sed -i 's/experimental-features .*/& ca-derivations ca-references nix-command flakes/' "$NIX_CONF_DIR"/nix.conf
export NIX_TESTS_CA_BY_DEFAULT=1
cd ..
source ./recursive.sh

View file

@ -1,8 +1,5 @@
source common.sh
# Globally enable the ca derivations experimental flag
sed -i 's/experimental-features = .*/& ca-derivations ca-references/' "$NIX_CONF_DIR/nix.conf"
clearStore
clearCache

View file

@ -173,10 +173,15 @@ needLocalStore() {
}
# Just to make it easy to find which tests should be fixed
buggyNeedLocalStore () {
buggyNeedLocalStore() {
needLocalStore
}
enableFeatures() {
local features="$1"
sed -i 's/experimental-features .*/& '"$features"'/' "$NIX_CONF_DIR"/nix.conf
}
set -x
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then

View file

@ -3,6 +3,8 @@ source common.sh
clearStore
clearProfiles
enableFeatures "ca-derivations ca-references"
# Make a flake.
flake1Dir=$TEST_ROOT/flake1
mkdir -p $flake1Dir
@ -82,13 +84,13 @@ nix profile wipe-history
# Test upgrade to CA package.
printf true > $flake1Dir/ca.nix
printf 3.0 > $flake1Dir/version
nix profile upgrade --extra-experimental-features ca-derivations 0
nix profile upgrade 0
nix profile history | grep "packages.$system.default: 1.0 -> 3.0"
# Test new install of CA package.
nix profile remove 0
printf 4.0 > $flake1Dir/version
printf Utrecht > $flake1Dir/who
nix profile install --extra-experimental-features ca-derivations $flake1Dir
nix profile install $flake1Dir
[[ $($TEST_HOME/.nix-profile/bin/hello) = "Hello Utrecht" ]]
[[ $(nix path-info --json $(realpath $TEST_HOME/.nix-profile/bin/hello) | jq -r .[].ca) =~ fixed:r:sha256: ]]