diff options
author | Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com> | 2022-06-29 17:59:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-29 17:59:22 +0200 |
commit | 4c8210095e7ed8de2eb4789b0ac6f9b4a39e394e (patch) | |
tree | 7a3907b09fb3cefd4b733365867b3f337d003170 /tests | |
parent | 3b18058969c57961ec6c7496020cce48bfb64edc (diff) | |
parent | f801d70ba70c130a26747aa5b60d233f37d34bfa (diff) |
Merge pull request #6233 from flox/nix-repl-flakes
Nix repl flakes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/repl.sh | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/tests/repl.sh b/tests/repl.sh index 9e6a59f18..c555560cc 100644 --- a/tests/repl.sh +++ b/tests/repl.sh @@ -55,15 +55,17 @@ testRepl testRepl --store "$TEST_ROOT/store?real=$NIX_STORE_DIR" testReplResponse () { - local response="$(nix repl <<< "$1")" - echo "$response" | grep -qs "$2" \ + local commands="$1"; shift + local expectedResponse="$1"; shift + local response="$(nix repl "$@" <<< "$commands")" + echo "$response" | grep -qs "$expectedResponse" \ || fail "repl command set: -$1 +$commands does not respond with: -$2 +$expectedResponse but with: @@ -76,3 +78,48 @@ testReplResponse ' :a { a = "2"; } "result: ${a}" ' "result: 2" + +testReplResponse ' +drvPath +' '".*-simple.drv"' \ +$testDir/simple.nix + +testReplResponse ' +drvPath +' '".*-simple.drv"' \ +--file $testDir/simple.nix --experimental-features 'ca-derivations' + +testReplResponse ' +drvPath +' '".*-simple.drv"' \ +--file $testDir/simple.nix --extra-experimental-features 'repl-flake ca-derivations' + +mkdir -p flake && cat <<EOF > flake/flake.nix +{ + outputs = { self }: { + foo = 1; + bar.baz = 2; + + changingThing = "beforeChange"; + }; +} +EOF +testReplResponse ' +foo + baz +' "3" \ + ./flake ./flake\#bar --experimental-features 'flakes repl-flake' + +# Test the `:reload` mechansim with flakes: +# - Eval `./flake#changingThing` +# - Modify the flake +# - Re-eval it +# - Check that the result has changed +replResult=$( ( +echo "changingThing" +sleep 1 # Leave the repl the time to eval 'foo' +sed -i 's/beforeChange/afterChange/' flake/flake.nix +echo ":reload" +echo "changingThing" +) | nix repl ./flake --experimental-features 'flakes repl-flake') +echo "$replResult" | grep -qs beforeChange +echo "$replResult" | grep -qs afterChange |