From 3784c66a46aea2cc3e26b8cff94b3a1f477888f1 Mon Sep 17 00:00:00 2001 From: regnat Date: Mon, 21 Jun 2021 15:17:31 +0200 Subject: Remove a possible existing store path when building CA derivations In case a previous interrupted build left a garbage path laying around, remove it before trying to move the path to its final location. Fix #4858 --- tests/ca/build-with-garbage-path.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 tests/ca/build-with-garbage-path.sh (limited to 'tests/ca/build-with-garbage-path.sh') diff --git a/tests/ca/build-with-garbage-path.sh b/tests/ca/build-with-garbage-path.sh new file mode 100755 index 000000000..e6f878702 --- /dev/null +++ b/tests/ca/build-with-garbage-path.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Regression test for https://github.com/NixOS/nix/issues/4858 + +source common.sh +sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_DIR"/nix.conf + +# Get the output path of `rootCA`, and put some garbage instead +outPath="$(nix-build ./content-addressed.nix -A rootCA --no-out-link)" +nix-store --delete "$outPath" +touch "$outPath" + +# The build should correctly remove the garbage and put the expected path instead +nix-build ./content-addressed.nix -A rootCA --no-out-link + +# Rebuild it. This shouldn’t overwrite the existing path +oldInode=$(stat -c '%i' "$outPath") +nix-build ./content-addressed.nix -A rootCA --no-out-link --arg seed 2 +newInode=$(stat -c '%i' "$outPath") +[[ "$oldInode" == "$newInode" ]] -- cgit v1.2.3 From addacfce4a71f33b50b6af321d6a8d67ca44ceed Mon Sep 17 00:00:00 2001 From: regnat Date: Mon, 26 Jul 2021 06:54:55 +0200 Subject: Allow running all the tests with the daemon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When `NIX_DAEMON_PACKAGE` is set, make all the tests use the Nix daemon. That way we can test every piece of Nix functionality both with and without the daemon. Tests for which using the daemon isn’t possible or doesn’t make sens can selectively be disabled with `needLocalStore` --- tests/ca/build-with-garbage-path.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/ca/build-with-garbage-path.sh') diff --git a/tests/ca/build-with-garbage-path.sh b/tests/ca/build-with-garbage-path.sh index e6f878702..9aa08a899 100755 --- a/tests/ca/build-with-garbage-path.sh +++ b/tests/ca/build-with-garbage-path.sh @@ -3,7 +3,8 @@ # Regression test for https://github.com/NixOS/nix/issues/4858 source common.sh -sed -i 's/experimental-features .*/& ca-derivations ca-references/' "$NIX_CONF_DIR"/nix.conf + +requireDaemonNewerThan "2.4pre20210621" # Get the output path of `rootCA`, and put some garbage instead outPath="$(nix-build ./content-addressed.nix -A rootCA --no-out-link)" -- cgit v1.2.3