From 53fabdc1d9b488aa9b16b9059980d5f5a37c0225 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 2 Jul 2024 17:11:27 +0200 Subject: [PATCH] Busywork --- scripts/flake-regressions.sh | 4 +- tests/functional/flakes/lazy-trees.sh | 45 ++++++++++++----------- tests/functional/flakes/patch.sh | 32 ++++++++-------- tests/functional/flakes/relative-paths.sh | 42 +++++++++++---------- tests/functional/flakes/tree-operators.sh | 16 ++++---- 5 files changed, 74 insertions(+), 65 deletions(-) diff --git a/scripts/flake-regressions.sh b/scripts/flake-regressions.sh index 56941285d0d..c8c6bee941d 100755 --- a/scripts/flake-regressions.sh +++ b/scripts/flake-regressions.sh @@ -9,7 +9,7 @@ cd flake-regressions status=0 -flakes=$(ls -d tests/*/*/* | sort | head -n50) +flakes=$(find tests -mindepth 3 -maxdepth 3 -type d -not -path '*/.*' | sort | head -n50) echo "Running flake tests..." @@ -21,7 +21,7 @@ for flake in $flakes; do continue fi - if ! REGENERATE=0 ./eval-flake.sh $flake; then + if ! REGENERATE=0 ./eval-flake.sh "$flake"; then status=1 echo "❌ $flake" else diff --git a/tests/functional/flakes/lazy-trees.sh b/tests/functional/flakes/lazy-trees.sh index 607c7e9d0db..56943f3737d 100644 --- a/tests/functional/flakes/lazy-trees.sh +++ b/tests/functional/flakes/lazy-trees.sh @@ -1,10 +1,12 @@ +#!/usr/bin/env bash + source common.sh flake1Dir=$TEST_ROOT/flake1 -mkdir -p $flake1Dir +mkdir -p "$flake1Dir" -cat > $flake1Dir/flake.nix < "$flake1Dir/flake.nix" < $flake1Dir/flake.nix < $flake1Dir/foo +cp ../config.nix "$flake1Dir/" +echo foo > "$flake1Dir/foo" # Add an uncopyable file to test laziness. -mkfifo $flake1Dir/fifo +mkfifo "$flake1Dir/fifo" -expectStderr 1 nix build --json --out-link $TEST_ROOT/result $flake1Dir#everything | grep 'has an unsupported type' +expectStderr 1 nix build --json --out-link "$TEST_ROOT/result" "$flake1Dir#everything" | grep 'has an unsupported type' -nix build --json --out-link $TEST_ROOT/result $flake1Dir#foo -[[ $(cat $TEST_ROOT/result) = foo ]] +nix build --json --out-link "$TEST_ROOT/result" "$flake1Dir#foo" +[[ $(cat "$TEST_ROOT/result") = foo ]] # FIXME: check that the name of `result` is `foo`, not `source`. # Check that traces/errors refer to the pretty-printed source path, not a virtual path. -nix eval $flake1Dir#trace 2>&1 | grep "trace: path $flake1Dir/foo" -expectStderr 1 nix eval $flake1Dir#throw 2>&1 | grep "error: path $flake1Dir/foo" -expectStderr 1 nix eval $flake1Dir#abort 2>&1 | grep "error:.*path $flake1Dir/foo" +nix eval "$flake1Dir#trace" 2>&1 | grep "trace: path $flake1Dir/foo" +expectStderr 1 nix eval "$flake1Dir#throw" 2>&1 | grep "error: path $flake1Dir/foo" +expectStderr 1 nix eval "$flake1Dir#abort" 2>&1 | grep "error:.*path $flake1Dir/foo" -nix build --out-link $TEST_ROOT/result $flake1Dir#drv1 -[[ $(cat $TEST_ROOT/result/foo) = foo ]] -[[ $(realpath $TEST_ROOT/result/foo) =~ $NIX_STORE_DIR/.*-foo$ ]] +nix build --out-link "$TEST_ROOT/result" "$flake1Dir#drv1" +[[ $(cat "$TEST_ROOT/result/foo") = foo ]] +[[ $(realpath "$TEST_ROOT/result/foo") =~ $NIX_STORE_DIR/.*-foo$ ]] # Check for warnings about passing `toString ./path` to a derivation. -nix build --out-link $TEST_ROOT/result $flake1Dir#drv2 2>&1 | grep "warning: derivation.*has an attribute that refers to source tree" -[[ $(readlink $TEST_ROOT/result/foo) =~ $NIX_STORE_DIR/lazylazy.*-source/foo$ ]] +nix build --out-link "$TEST_ROOT/result" "$flake1Dir#drv2" 2>&1 | grep "warning: derivation.*has an attribute that refers to source tree" +[[ $(readlink "$TEST_ROOT/result/foo") =~ $NIX_STORE_DIR/lazylazy.*-source/foo$ ]] # If the source tree can be hashed, the virtual path will be rewritten # to the path that would exist if the source tree were copied to the # Nix store. -rm $flake1Dir/fifo -nix build --out-link $TEST_ROOT/result $flake1Dir#drv2 +rm "$flake1Dir/fifo" +nix build --out-link "$TEST_ROOT/result" "$flake1Dir#drv2" # But we don't *actually* copy it. -(! realpath $TEST_ROOT/result/foo) +(! realpath "$TEST_ROOT/result/foo") # Force the path to exist. -path=$(nix eval --raw $flake1Dir#everything) -realpath $TEST_ROOT/result/foo +path=$(nix eval --raw "$flake1Dir#everything") +[[ -e $path ]] +realpath "$TEST_ROOT/result/foo" diff --git a/tests/functional/flakes/patch.sh b/tests/functional/flakes/patch.sh index b276303de28..89f54f78eaf 100644 --- a/tests/functional/flakes/patch.sh +++ b/tests/functional/flakes/patch.sh @@ -1,13 +1,15 @@ +#! /usr/bin/env bash + source common.sh flake1Dir=$TEST_ROOT/flake1 flake2Dir=$TEST_ROOT/flake2 flake3Dir=$TEST_ROOT/flake3 -rm -rf $flake1Dir $flake2Dir $flake3Dir -mkdir -p $flake1Dir/dir $flake2Dir $flake3Dir +rm -rf "$flake1Dir" "$flake2Dir" "$flake3Dir" +mkdir -p "$flake1Dir/dir" "$flake2Dir" "$flake3Dir" -cat > $flake2Dir/flake.nix < "$flake2Dir/flake.nix" < $flake2Dir/flake.nix < $flake2Dir/z.nix +echo "10 + 20" > "$flake2Dir/z.nix" -cat > $flake1Dir/dir/flake.nix < "$flake1Dir/dir/flake.nix" < $flake1Dir/dir/flake.nix < $flake1Dir/p1.patch < "$flake1Dir/p1.patch" < $flake1Dir/p2.patch < "$flake1Dir/p2.patch" < $flake1Dir/dir/p3.patch < "$flake1Dir/dir/p3.patch" < $flake3Dir/flake.nix < "$flake3Dir/flake.nix" < $flake3Dir/flake.nix < $rootFlake/flake.nix < "$rootFlake/flake.nix" < $rootFlake/flake.nix < $subflake0/flake.nix < "$subflake0/flake.nix" < $subflake0/flake.nix < $subflake1/flake.nix < "$subflake1/flake.nix" < $subflake1/flake.nix < $subflake2/flake.nix < "$subflake2/flake.nix" < $subflake2/flake.nix < $rootFlake/flake.nix < "$rootFlake/flake.nix" < $rootFlake/flake.nix < $flake1Dir/flake.nix < "$flake1Dir/flake.nix" < $flake1Dir/flake.nix <