diff --git a/packaging/hydra.nix b/packaging/hydra.nix index cef740fa1179..2d86a141e75d 100644 --- a/packaging/hydra.nix +++ b/packaging/hydra.nix @@ -440,12 +440,8 @@ rec { in pkgs.runCommand "install-tests" { againstSelf = testNixVersions pkgs pkgs.nix; - againstCurrentLatest = - # FIXME: temporarily disable this on macOS because of #3605. - if system == "x86_64-linux" then testNixVersions pkgs pkgs.nixVersions.latest else null; - # Disabled because the latest stable version doesn't handle - # `NIX_DAEMON_SOCKET_PATH` which is required for the tests to work - # againstLatestStable = testNixVersions pkgs pkgs.nixStable; + againstCurrentLatest = testNixVersions pkgs pkgs.nixVersions.latest; + againstLatestStable = testNixVersions pkgs pkgs.nixVersions.stable; } "touch $out" ); diff --git a/tests/functional/common/characterisation/framework.sh b/tests/functional/common/characterisation/framework.sh index b33c165fd2c3..1235b9179176 100644 --- a/tests/functional/common/characterisation/framework.sh +++ b/tests/functional/common/characterisation/framework.sh @@ -2,6 +2,19 @@ badTestNames=() +function reportDiffAcceptFailure() { + local -r testName=$1 + # We receive the diff unified stdout/stderr output as the argument + printf '%s' "$2" >&2 + diffExitCode=$? + echo >&2 "subtest '$testName' failed: characterised output of $testName not as expected" +} + +function reportDiffAcceptSuccess() { + # Do nothing by default + : +} + # Golden test support # # Test that the output of the given test matches what is expected. If @@ -16,15 +29,22 @@ function diffAndAcceptInner() { if test -e "$expected"; then local -r expectedOrEmpty="$expected" else - local -r expectedOrEmpty=common/characterisation/empty + local -r expectedOrEmpty=$_NIX_TEST_SOURCE_DIR/common/characterisation/empty fi # Diff so we get a nice message - if ! diff >&2 --color=always --unified "$expectedOrEmpty" "$got"; then - echo >&2 "FAIL: evaluation result of $testName not as expected" + set +e + diffOutput=$(diff 2>&1 --color=always --unified "$expectedOrEmpty" "$got") + diffExitCode=$? + set -e + + if ((diffExitCode != 0)); then + reportDiffAcceptFailure "$diffOutput" "$testName" # shellcheck disable=SC2034 badDiff=1 badTestNames+=("$testName") + else + reportDiffAcceptSuccess fi # Update expected if `_NIX_TEST_ACCEPT` is `1`. (Comparing against diff --git a/tests/functional/common/functions.sh b/tests/functional/common/functions.sh index cbeb1daaa6d9..54f52ea28486 100644 --- a/tests/functional/common/functions.sh +++ b/tests/functional/common/functions.sh @@ -374,7 +374,7 @@ initGitRepo() { local extraArgs="${2-}" # shellcheck disable=SC2086 # word splitting of extraArgs is intended - git -C "$repo" init $extraArgs + git -C "$repo" init --initial-branch=master $extraArgs git -C "$repo" config user.email "foobar@example.com" git -C "$repo" config user.name "Foobar" } diff --git a/tests/functional/git/packed-refs-no-cache.sh b/tests/functional/git/packed-refs-no-cache.sh index 33ffd5fa33e9..fd369e6b1e44 100644 --- a/tests/functional/git/packed-refs-no-cache.sh +++ b/tests/functional/git/packed-refs-no-cache.sh @@ -21,11 +21,7 @@ repo=$TEST_ROOT/./git export _NIX_FORCE_HTTP=1 -rm -rf "$repo" "${repo}-tmp" "$TEST_HOME/.cache/nix" - -git init --initial-branch="master" "$repo" -git -C "$repo" config user.email "nix-tests@example.com" -git -C "$repo" config user.name "Nix Tests" +createGitRepo "$repo" echo "hello world" > "$repo/hello_world" git -C "$repo" add hello_world diff --git a/tests/functional/meson.build b/tests/functional/meson.build index b3f57f64db53..93a50dc9e3fa 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -7,7 +7,7 @@ project( 'warning_level=1', 'errorlogs=true', # Please print logs for tests that fail ], - meson_version : '>= 1.3', + meson_version : '>= 1.8', license : 'LGPL-2.1-or-later', ) @@ -206,27 +206,8 @@ if nix_store.found() endif -# Plugin tests require shared libraries support. -nix_expr = dependency('nix-expr', required : false) -if nix_expr.found() and get_option('default_library') != 'static' - add_languages('cpp') - subdir('plugins') - plugin_test_deps = [ libplugintest ] - if get_option('plugin-c-api') and not host_machine.system().startswith( - 'windows', - ) - plugin_test_deps += [ libplugintest_dlsym ] - endif - suites += { - 'name' : 'plugins', - 'deps' : plugin_test_deps, - 'tests' : [ - 'plugins.sh', - ], - 'workdir' : meson.current_source_dir(), - } -endif - +subdir('suites') +# TODO: Lay out the tests suites in a less flat manner. subdir('ca') subdir('dyn-drv') subdir('flakes') @@ -260,6 +241,9 @@ foreach suite : suites meson.current_build_dir() / 'asan-log', ) + overrides = suite.get('overrides', {}).get(script, {}) + protocol = overrides.get('protocol', 'exitcode') + test( name, bash, @@ -280,7 +264,7 @@ foreach suite : suites 'TEST_NAME' : name, 'NIX_REMOTE' : '', 'PS4' : '+(${BASH_SOURCE[0]-$0}:$LINENO) ', - }, + } + suite.get('env', {}), # Some tests take 15+ seconds even on an otherwise idle machine; # on a loaded machine this can easily drive them to failure. Give # them more time than the default of 30 seconds. @@ -288,6 +272,7 @@ foreach suite : suites # Used for target dependency/ordering tracking, not adding compiler flags or anything. depends : deps, workdir : workdir, + protocol : protocol, ) endforeach endforeach diff --git a/tests/functional/plugins.sh b/tests/functional/plugins.sh deleted file mode 100755 index 948ff1f77eb2..000000000000 --- a/tests/functional/plugins.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -source common.sh - -findPlugin() { - local name="$1" - - for ext in so dylib; do - local plugin="${_NIX_TEST_BUILD_DIR}/plugins/${name}.$ext" - if [[ -f "$plugin" ]]; then - printf '%s\n' "$plugin" - return 0 - fi - done - - return 1 -} - -plugin=$(findPlugin libplugintest) - -res=$(nix --option setting-set true --option plugin-files "$plugin" eval --expr builtins.anotherNull) - -[ "$res"x = "nullx" ] - -if plugin_dlsym=$(findPlugin libplugintest_dlsym); then - nix --option plugin-files "$plugin_dlsym" eval --expr 0 >/dev/null -fi diff --git a/tests/functional/plugins/meson.build b/tests/functional/plugins/meson.build deleted file mode 100644 index 4efc9b2a7e8f..000000000000 --- a/tests/functional/plugins/meson.build +++ /dev/null @@ -1,20 +0,0 @@ -cpp = meson.get_compiler('cpp') -dl_dep = cpp.find_library('dl', required : false) - -libplugintest = shared_module( - 'plugintest', - 'plugintest.cc', - dependencies : [ - dependency('nix-expr'), - ], - build_by_default : false, -) - -if get_option('plugin-c-api') and not host_machine.system().startswith('windows') - libplugintest_dlsym = shared_module( - 'plugintest_dlsym', - 'plugintest_dlsym.cc', - dependencies : [ dl_dep ], - build_by_default : false, - ) -endif diff --git a/tests/functional/repl.sh b/tests/functional/repl.sh index d63ca76b4e3a..cabb820c9b9e 100755 --- a/tests/functional/repl.sh +++ b/tests/functional/repl.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash source common.sh -source common/characterisation/framework.sh testDir="$PWD" cd "$TEST_ROOT" @@ -25,13 +24,6 @@ import $testDir/undefined-variable.nix TODO_NixOS -# FIXME: repl tests fail on systems with stack limits -stack_ulimit="$(ulimit -Hs)" -stack_required="$((64 * 1024 * 1024))" -if [[ "$stack_ulimit" != "unlimited" ]]; then - ((stack_ulimit < stack_required)) && skipTest "repl tests cannot run on systems with stack size <$stack_required ($stack_ulimit)" -fi - testRepl () { local nixArgs nixArgs=("$@") @@ -79,270 +71,3 @@ testRepl () { testRepl # Same thing (kind-of), but with a remote store. testRepl --store "$TEST_ROOT/other-root?real=$NIX_STORE_DIR" - -# Remove ANSI escape sequences. They can prevent grep from finding a match. -stripColors () { - sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' -} - -testReplResponseGeneral () { - local grepMode commands expectedResponse response - grepMode="$1"; shift - commands="$1"; shift - # Expected response can contain newlines. - # grep can't handle multiline patterns, so replace newlines with TEST_NEWLINE - # in both expectedResponse and response. - # awk ORS always adds a trailing record separator, so we strip it with sed. - expectedResponse="$(printf '%s' "$1" | awk 1 ORS=TEST_NEWLINE | sed 's/TEST_NEWLINE$//')"; shift - # We don't need to strip trailing record separator here, since extra data is ok. - response="$(nix repl "$@" <<< "$commands" 2>&1 | stripColors | awk 1 ORS=TEST_NEWLINE)" - printf '%s' "$response" | grepQuiet "$grepMode" -s "$expectedResponse" \ - || fail "$(echo "repl command set: - -$commands - -does not respond with: - ---- -$expectedResponse ---- - -but with: - ---- -$response ---- - -" | sed 's/TEST_NEWLINE/\n/g')" -} - -testReplResponse () { - testReplResponseGeneral --basic-regexp "$@" -} - -testReplResponseNoRegex () { - testReplResponseGeneral --fixed-strings "$@" -} - -testReplResponse ' -drvPath -' '".*-simple.drv"' \ ---file "$testDir/simple.nix" - -testReplResponse ' -drvPath -' '".*-simple.drv"' \ ---file "$testDir/simple.nix" --experimental-features 'ca-derivations' - -# `--file` autocalls, `--expr` does not. -testReplResponse ' -drvPath -' '".*-simple.drv"' \ ---file "$testDir/repl/function.nix" - -testReplResponse ' -' 'while evaluating an attribute set to be merged in the global scope' \ ---expr '{ x ? 1 }: import '"$testDir"'/simple.nix' - -mkdir -p flake && cat < flake/flake.nix -{ - outputs = { self }: { - foo = 1; - bar.baz = 2; - - changingThing = "beforeChange"; - }; -} -EOF -testReplResponse ' -foo + baz -' "3" \ - ./flake ./flake\#bar --experimental-features 'flakes' - -# Test the `:reload` mechanism with flakes: -# - Eval `./flake#changingThing` -# - Modify the flake -# - Re-eval it -# - Check that the result has changed -mkfifo repl_fifo -touch repl_output -nix repl ./flake --experimental-features 'flakes' < repl_fifo >> repl_output 2>&1 & -repl_pid=$! -exec 3>repl_fifo # Open fifo for writing -echo "changingThing" >&3 -for i in $(seq 1 1000); do - if grep -q "beforeChange" repl_output; then - break - fi - cat repl_output - sleep 0.1 -done -if [[ "$i" -eq 100 ]]; then - echo "Timed out waiting for beforeChange" - exit 1 -fi - -sed -i 's/beforeChange/afterChange/' flake/flake.nix - -# Send reload and second command -echo ":reload" >&3 -echo "changingThing" >&3 -echo "exit" >&3 -exec 3>&- # Close fifo -wait $repl_pid # Wait for process to finish -grep -q "afterChange" repl_output - -# Regression: `:reload` on a flake loaded from a *git* work tree must pick up -# uncommitted changes. Guards against the per-process workdir-info cache -# pinning the tree to the rev seen on first load. -if [[ $(type -p git) ]]; then - createGitRepo gitflake - cat > gitflake/flake.nix <> repl_output 2>&1 & - repl_pid=$! - exec 3>repl_fifo - echo "changingThing" >&3 - for _ in $(seq 1 1000); do - grep -q "beforeChange" repl_output && break - sleep 0.1 - done - grep -q "beforeChange" repl_output || fail "git flake didn't load" - sed -i 's/beforeChange/afterChange/' gitflake/flake.nix - echo ":reload" >&3 - echo "changingThing" >&3 - echo "exit" >&3 - exec 3>&- - wait $repl_pid - grep -q "afterChange" repl_output || fail ":reload didn't pick up git work tree change" -fi - -# Regression: a failed `:lf` must not be remembered for `:reload`, -# and an error in one loaded file must not drop later ones from the reload list. -testReplResponseNoRegex ' -:lf ./does-not-exist-flake -:lf ./flake -:r -foo -' '1' \ - --experimental-features 'flakes' - -# Don't prompt for more input when getting unexpected EOF in imported files. -testReplResponse " -import $testDir/lang/parse-fail-eof-pos.nix -" \ -'.*error: syntax error, unexpected end of file.*' - -EDITOR='cat' nix repl <<< ':e derivation' 2>&1 | grepQuiet 'derivationStrict' -EDITOR='cat' nix repl <<< ':e ' 2>&1 | grepQuiet 'builtin:fetchurl' - -# TODO: move init to characterisation/framework.sh -badDiff=0 -badExitCode=0 - -nixVersion="$(nix eval --impure --raw --expr 'builtins.nixVersion' --extra-experimental-features nix-command)" - -# TODO: write a repl interacter for testing. Papering over the differences between readline / editline and between platforms is a pain. - -# I couldn't get readline and editline to agree on the newline before the prompt, -# so let's just force it to be one empty line. -stripEmptyLinesBeforePrompt() { - # --null-data: treat input as NUL-terminated instead of newline-terminated - sed --null-data 's/\n\n*nix-repl>/\n\nnix-repl>/g' -} - -# We don't get a final prompt on darwin, so we strip this as well. -stripFinalPrompt() { - # Strip the final prompt and/or any trailing spaces - sed --null-data \ - -e 's/\(.*[^\n]\)\n\n*nix-repl>[ \n]*$/\1/' \ - -e 's/[ \n]*$/\n/' -} - -filterReplOutput () { - # That is right, we are also filtering out the testdir _without underscores_. - # This is crazy, but without it, GHA will fail to run the tests, showing paths - # _with_ underscores in the set -x log, but _without_ underscores in the - # supposed nix repl output. I have looked in a number of places, but I cannot - # find a mechanism that could cause this to happen. - local testDirNoUnderscores - testDirNoUnderscores="${testDir//_/}" - - stripColors \ - | tr -d '\0' \ - | stripEmptyLinesBeforePrompt \ - | stripFinalPrompt \ - | sed \ - -e "s@$testDir@/path/to/tests/functional@g" \ - -e "s@$testDirNoUnderscores@/path/to/tests/functional@g" \ - -e "s@$nixVersion@@g" \ - | grep -vF $'warning: you don\'t have Internet access; disabling some network-dependent features' \ - ; -} - -runRepl () { - _NIX_TEST_RAW_MARKDOWN=1 \ - _NIX_TEST_REPL_ECHO=1 \ - nix repl "$@" 2>&1 | filterReplOutput -} - -runDebugRepl () { - _NIX_TEST_RAW_MARKDOWN=1 \ - _NIX_TEST_REPL_ECHO=1 \ - nix eval --file "$1" --debugger "${@:2}" 2>&1 | filterReplOutput -} - -for test in $(cd "$testDir/repl"; echo *.in); do - test="$(basename "$test" .in)" - in="$testDir/repl/$test.in" - actual="$TEST_ROOT/$test.actual" - expected="$testDir/repl/$test.expected" - declare -a flags=() - if test -e "$testDir/repl/$test.flags"; then - read -r -a flags < "$testDir/repl/$test.flags" - fi - - # Allow putting comments (lines starting with `# COM:`) in the test for - # documentation purposes. Regular comments are not skipped, since those are - # also interpreted by the repl. - inputWithoutComments=$(grep -Ev '^[[:space:]]*#[[:space:]]*COM:' "$in") - - if [ -f "$testDir/repl/$test.in.debugexpr.nix" ]; then - if [[ "$test" =~ debugger-fail-.* ]]; then - expectedFail=1 - elif [[ "$test" =~ debugger-okay-.* ]]; then - expectedFail=0 - else - die "unexpected debugger test name: '$test', should be either debugger-okay-* or debugger-fail-*" - fi - - set +e - (cd "$testDir/repl"; set +x; echo "$inputWithoutComments" | runDebugRepl "$testDir/repl/$test.in.debugexpr.nix" "${flags[@]}" 2>&1) > "$actual" - debuggerTestCode=$? - set -e - - if ((expectedFail == 0 && debuggerTestCode != 0)); then - echo "test failed: $test (exit code $debuggerTestCode)" >&2 - badExitCode=1 - elif ((expectedFail == 1 && debuggerTestCode == 0)); then - echo "test failed: $test unexpectedly succeeded" >&2 - badExitCode=1 - fi - else - (cd "$testDir/repl"; set +x; echo "$inputWithoutComments" | runRepl "${flags[@]}" 2>&1) > "$actual" || { - echo "test failed: $test (exit code $?)" >&2 - badExitCode=1 - } - fi - - diffAndAcceptInner "$test" "$actual" "$expected" -done - -characterisationTestExit diff --git a/tests/functional/repl/characterisation/empty b/tests/functional/repl/characterisation/empty deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/tests/functional/repl/function.nix b/tests/functional/repl/function.nix deleted file mode 100644 index 6f9b6071e514..000000000000 --- a/tests/functional/repl/function.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ - x ? 1, -}: -import ../simple.nix diff --git a/tests/functional/suites/meson.build b/tests/functional/suites/meson.build new file mode 100644 index 000000000000..e59a9e606a70 --- /dev/null +++ b/tests/functional/suites/meson.build @@ -0,0 +1,7 @@ +nix_expr = dependency('nix-expr', required : false) + +if nix_expr.found() and get_option('default_library') != 'static' + subdir('plugins') +endif + +subdir('repl') diff --git a/tests/functional/suites/plugins/common.sh.in b/tests/functional/suites/plugins/common.sh.in new file mode 100644 index 000000000000..8bc40751c73b --- /dev/null +++ b/tests/functional/suites/plugins/common.sh.in @@ -0,0 +1,21 @@ +set +x + +source "$_NIX_TEST_SOURCE_DIR"/common.sh + +set -x + +findPlugin() { + set +x + + local name="$1" + + for ext in so dylib; do + local plugin="@PLUGINS_BUILD_DIR@/${name}.$ext" + if [[ -f "$plugin" ]]; then + printf '%s\n' "$plugin" + return 0 + fi + done + + return 1 +} diff --git a/tests/functional/suites/plugins/export-c-api.sh b/tests/functional/suites/plugins/export-c-api.sh new file mode 100644 index 000000000000..1c384b0ce371 --- /dev/null +++ b/tests/functional/suites/plugins/export-c-api.sh @@ -0,0 +1,6 @@ +# shellcheck shell=bash + +# Test whether -c library API symbols are exported and can be looked up via +# dlsym. + +nix --option plugin-files "$(findPlugin libplugintest_dlsym)" eval --expr 0 >/dev/null diff --git a/tests/functional/suites/plugins/meson.build b/tests/functional/suites/plugins/meson.build new file mode 100644 index 000000000000..dd1dc374a8d1 --- /dev/null +++ b/tests/functional/suites/plugins/meson.build @@ -0,0 +1,47 @@ +add_languages('cpp', native : false) +cpp = meson.get_compiler('cpp') +dl_dep = cpp.find_library('dl', required : false) + +plugin_test_deps = [] +plugin_tests = [] + +libplugintest = shared_module( + 'plugintest', + 'src/plugintest.cc', + dependencies : [ + dependency('nix-expr'), + ], + build_by_default : false, +) + +plugin_tests += [ 'register-setting-and-primop.sh' ] +plugin_test_deps += [ libplugintest ] + +if get_option('plugin-c-api') and not host_machine.system().startswith('windows') + libplugintest_dlsym = shared_module( + 'plugintest_dlsym', + 'src/plugintest_dlsym.cc', + dependencies : [ dl_dep ], + build_by_default : false, + ) + + plugin_tests += [ 'export-c-api.sh' ] + plugin_test_deps += [ libplugintest_dlsym ] +endif + +plugin_test_conf = configuration_data() +plugin_test_conf.set('PLUGINS_BUILD_DIR', meson.current_build_dir()) + +plugin_test_common = configure_file( + input : 'common.sh.in', + output : 'common.sh', + configuration : plugin_test_conf, +) + +suites += { + 'name' : 'plugins', + 'deps' : plugin_test_deps, + 'tests' : plugin_tests, + 'workdir' : meson.current_source_dir(), + 'env' : {'BASH_ENV' : plugin_test_common.full_path()}, +} diff --git a/tests/functional/suites/plugins/register-setting-and-primop.sh b/tests/functional/suites/plugins/register-setting-and-primop.sh new file mode 100644 index 000000000000..09315926524f --- /dev/null +++ b/tests/functional/suites/plugins/register-setting-and-primop.sh @@ -0,0 +1,8 @@ +# shellcheck shell=bash + +# The loaded plugin registers a primop that behaves differently depending on a +# setting value. + +plugin=$(findPlugin libplugintest) +res=$(nix --option setting-set true --option plugin-files "$plugin" eval --expr builtins.anotherNull) +[ "$res"x = "nullx" ] diff --git a/tests/functional/plugins/plugintest.cc b/tests/functional/suites/plugins/src/plugintest.cc similarity index 100% rename from tests/functional/plugins/plugintest.cc rename to tests/functional/suites/plugins/src/plugintest.cc diff --git a/tests/functional/plugins/plugintest_dlsym.cc b/tests/functional/suites/plugins/src/plugintest_dlsym.cc similarity index 100% rename from tests/functional/plugins/plugintest_dlsym.cc rename to tests/functional/suites/plugins/src/plugintest_dlsym.cc diff --git a/tests/functional/repl/add-lots-of-variables.expected b/tests/functional/suites/repl/cases/add-lots-of-variables.expected similarity index 100% rename from tests/functional/repl/add-lots-of-variables.expected rename to tests/functional/suites/repl/cases/add-lots-of-variables.expected diff --git a/tests/functional/repl/add-lots-of-variables.in b/tests/functional/suites/repl/cases/add-lots-of-variables.in similarity index 100% rename from tests/functional/repl/add-lots-of-variables.in rename to tests/functional/suites/repl/cases/add-lots-of-variables.in diff --git a/tests/functional/repl/add-overwritten-symbol-env.expected b/tests/functional/suites/repl/cases/add-overwritten-symbol-env.expected similarity index 100% rename from tests/functional/repl/add-overwritten-symbol-env.expected rename to tests/functional/suites/repl/cases/add-overwritten-symbol-env.expected diff --git a/tests/functional/repl/add-overwritten-symbol-env.in b/tests/functional/suites/repl/cases/add-overwritten-symbol-env.in similarity index 100% rename from tests/functional/repl/add-overwritten-symbol-env.in rename to tests/functional/suites/repl/cases/add-overwritten-symbol-env.in diff --git a/tests/functional/repl/add-variable-with-spaces.expected b/tests/functional/suites/repl/cases/add-variable-with-spaces.expected similarity index 100% rename from tests/functional/repl/add-variable-with-spaces.expected rename to tests/functional/suites/repl/cases/add-variable-with-spaces.expected diff --git a/tests/functional/repl/add-variable-with-spaces.in b/tests/functional/suites/repl/cases/add-variable-with-spaces.in similarity index 100% rename from tests/functional/repl/add-variable-with-spaces.in rename to tests/functional/suites/repl/cases/add-variable-with-spaces.in diff --git a/tests/functional/repl/attribute-set.nix b/tests/functional/suites/repl/cases/attribute-set.nix similarity index 100% rename from tests/functional/repl/attribute-set.nix rename to tests/functional/suites/repl/cases/attribute-set.nix diff --git a/tests/functional/repl/debugger-fail-throw-env-1.expected b/tests/functional/suites/repl/cases/debugger-fail-throw-env-1.expected similarity index 64% rename from tests/functional/repl/debugger-fail-throw-env-1.expected rename to tests/functional/suites/repl/cases/debugger-fail-throw-env-1.expected index 921395b8f928..7926a13b1306 100644 --- a/tests/functional/repl/debugger-fail-throw-env-1.expected +++ b/tests/functional/suites/repl/cases/debugger-fail-throw-env-1.expected @@ -12,22 +12,22 @@ abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit nix-repl> :quit error: - … while evaluating the file '/path/to/tests/functional/repl/debugger-fail-throw-env-1.in.debugexpr.nix': + … while evaluating the file '/path/to/repl/suite/cases/debugger-fail-throw-env-1.in.debugexpr.nix': … from call site - at /path/to/tests/functional/repl/debugger-fail-throw-env-1.in.debugexpr.nix:1:1: + at /path/to/repl/suite/cases/debugger-fail-throw-env-1.in.debugexpr.nix:1:1: 1| (_: throw "oh snap") 42 | ^ 2| … while calling anonymous lambda - at /path/to/tests/functional/repl/debugger-fail-throw-env-1.in.debugexpr.nix:1:2: + at /path/to/repl/suite/cases/debugger-fail-throw-env-1.in.debugexpr.nix:1:2: 1| (_: throw "oh snap") 42 | ^ 2| … while calling the 'throw' builtin - at /path/to/tests/functional/repl/debugger-fail-throw-env-1.in.debugexpr.nix:1:5: + at /path/to/repl/suite/cases/debugger-fail-throw-env-1.in.debugexpr.nix:1:5: 1| (_: throw "oh snap") 42 | ^ 2| diff --git a/tests/functional/repl/debugger-fail-throw-env-1.in b/tests/functional/suites/repl/cases/debugger-fail-throw-env-1.in similarity index 100% rename from tests/functional/repl/debugger-fail-throw-env-1.in rename to tests/functional/suites/repl/cases/debugger-fail-throw-env-1.in diff --git a/tests/functional/repl/debugger-fail-throw-env-1.in.debugexpr.nix b/tests/functional/suites/repl/cases/debugger-fail-throw-env-1.in.debugexpr.nix similarity index 100% rename from tests/functional/repl/debugger-fail-throw-env-1.in.debugexpr.nix rename to tests/functional/suites/repl/cases/debugger-fail-throw-env-1.in.debugexpr.nix diff --git a/tests/functional/repl/debugger-fail-throw-env-2.expected b/tests/functional/suites/repl/cases/debugger-fail-throw-env-2.expected similarity index 64% rename from tests/functional/repl/debugger-fail-throw-env-2.expected rename to tests/functional/suites/repl/cases/debugger-fail-throw-env-2.expected index 3eb47bdf53aa..e2f9d5ac47ba 100644 --- a/tests/functional/repl/debugger-fail-throw-env-2.expected +++ b/tests/functional/suites/repl/cases/debugger-fail-throw-env-2.expected @@ -20,7 +20,7 @@ abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit nix-repl> :bt 0: error: oh snap -/path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix:5:23 +/path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix:5:23 4| with x; 5| (_: builtins.seq x.a (throw "oh snap")) x.a @@ -28,7 +28,7 @@ nix-repl> :bt 6| 1: while calling a function -/path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix:5:23 +/path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix:5:23 4| with x; 5| (_: builtins.seq x.a (throw "oh snap")) x.a @@ -36,7 +36,7 @@ nix-repl> :bt 6| 2: while calling a function -/path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix:5:5 +/path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix:5:5 4| with x; 5| (_: builtins.seq x.a (throw "oh snap")) x.a @@ -44,7 +44,7 @@ nix-repl> :bt 6| 3: while calling anonymous lambda -/path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix:5:2 +/path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix:5:2 4| with x; 5| (_: builtins.seq x.a (throw "oh snap")) x.a @@ -52,7 +52,7 @@ nix-repl> :bt 6| 4: while calling a function -/path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix:5:1 +/path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix:5:1 4| with x; 5| (_: builtins.seq x.a (throw "oh snap")) x.a @@ -61,35 +61,35 @@ nix-repl> :bt 5: while evaluating a 'let' expression -6: while evaluating the file '/path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix': +6: while evaluating the file '/path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix': error: - … while evaluating the file '/path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix': + … while evaluating the file '/path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix': … from call site - at /path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix:5:1: + at /path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix:5:1: 4| with x; 5| (_: builtins.seq x.a (throw "oh snap")) x.a | ^ 6| … while calling anonymous lambda - at /path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix:5:2: + at /path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix:5:2: 4| with x; 5| (_: builtins.seq x.a (throw "oh snap")) x.a | ^ 6| … while calling the 'seq' builtin - at /path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix:5:5: + at /path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix:5:5: 4| with x; 5| (_: builtins.seq x.a (throw "oh snap")) x.a | ^ 6| … while calling the 'throw' builtin - at /path/to/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix:5:23: + at /path/to/repl/suite/cases/debugger-fail-throw-env-2.in.debugexpr.nix:5:23: 4| with x; 5| (_: builtins.seq x.a (throw "oh snap")) x.a | ^ diff --git a/tests/functional/repl/debugger-fail-throw-env-2.in b/tests/functional/suites/repl/cases/debugger-fail-throw-env-2.in similarity index 100% rename from tests/functional/repl/debugger-fail-throw-env-2.in rename to tests/functional/suites/repl/cases/debugger-fail-throw-env-2.in diff --git a/tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix b/tests/functional/suites/repl/cases/debugger-fail-throw-env-2.in.debugexpr.nix similarity index 100% rename from tests/functional/repl/debugger-fail-throw-env-2.in.debugexpr.nix rename to tests/functional/suites/repl/cases/debugger-fail-throw-env-2.in.debugexpr.nix diff --git a/tests/functional/repl/debugger-okay-break.expected b/tests/functional/suites/repl/cases/debugger-okay-break.expected similarity index 59% rename from tests/functional/repl/debugger-okay-break.expected rename to tests/functional/suites/repl/cases/debugger-okay-break.expected index 0cec2398a75e..9d1b094b65b7 100644 --- a/tests/functional/repl/debugger-okay-break.expected +++ b/tests/functional/suites/repl/cases/debugger-okay-break.expected @@ -8,7 +8,7 @@ nix-repl> :bt 0: error: breakpoint reached 1: while calling a function -/path/to/tests/functional/repl/debugger-okay-break.in.debugexpr.nix:5:1 +/path/to/repl/suite/cases/debugger-okay-break.in.debugexpr.nix:5:1 4| in 5| builtins.break othervar @@ -17,14 +17,14 @@ nix-repl> :bt 2: while evaluating a 'let' expression -3: while evaluating the file '/path/to/tests/functional/repl/debugger-okay-break.in.debugexpr.nix': +3: while evaluating the file '/path/to/repl/suite/cases/debugger-okay-break.in.debugexpr.nix': nix-repl> :backtrace 0: error: breakpoint reached 1: while calling a function -/path/to/tests/functional/repl/debugger-okay-break.in.debugexpr.nix:5:1 +/path/to/repl/suite/cases/debugger-okay-break.in.debugexpr.nix:5:1 4| in 5| builtins.break othervar @@ -33,7 +33,7 @@ nix-repl> :backtrace 2: while evaluating a 'let' expression -3: while evaluating the file '/path/to/tests/functional/repl/debugger-okay-break.in.debugexpr.nix': +3: while evaluating the file '/path/to/repl/suite/cases/debugger-okay-break.in.debugexpr.nix': nix-repl> :p somevar hello diff --git a/tests/functional/repl/debugger-okay-break.in b/tests/functional/suites/repl/cases/debugger-okay-break.in similarity index 100% rename from tests/functional/repl/debugger-okay-break.in rename to tests/functional/suites/repl/cases/debugger-okay-break.in diff --git a/tests/functional/repl/debugger-okay-break.in.debugexpr.nix b/tests/functional/suites/repl/cases/debugger-okay-break.in.debugexpr.nix similarity index 100% rename from tests/functional/repl/debugger-okay-break.in.debugexpr.nix rename to tests/functional/suites/repl/cases/debugger-okay-break.in.debugexpr.nix diff --git a/tests/functional/repl/debugger-okay-ignore-try.expected b/tests/functional/suites/repl/cases/debugger-okay-ignore-try.expected similarity index 90% rename from tests/functional/repl/debugger-okay-ignore-try.expected rename to tests/functional/suites/repl/cases/debugger-okay-ignore-try.expected index 7d4e72fdaeab..1c168f96c47d 100644 --- a/tests/functional/repl/debugger-okay-ignore-try.expected +++ b/tests/functional/suites/repl/cases/debugger-okay-ignore-try.expected @@ -8,7 +8,7 @@ nix-repl> :bt 0: error: breakpoint reached 1: while calling a function -/path/to/tests/functional/repl/debugger-okay-ignore-try.in.debugexpr.nix:6:13 +/path/to/repl/suite/cases/debugger-okay-ignore-try.in.debugexpr.nix:6:13 5| let 6| bricked = break tried; @@ -19,7 +19,7 @@ nix-repl> :bt 3: while evaluating a 'let' expression -4: while evaluating the file '/path/to/tests/functional/repl/debugger-okay-ignore-try.in.debugexpr.nix': +4: while evaluating the file '/path/to/repl/suite/cases/debugger-okay-ignore-try.in.debugexpr.nix': nix-repl> :st 3 @@ -71,7 +71,7 @@ nix-repl> :p tried nix-repl> :st 1 1: while calling a function -/path/to/tests/functional/repl/debugger-okay-ignore-try.in.debugexpr.nix:6:13 +/path/to/repl/suite/cases/debugger-okay-ignore-try.in.debugexpr.nix:6:13 5| let 6| bricked = break tried; diff --git a/tests/functional/repl/debugger-okay-ignore-try.flags b/tests/functional/suites/repl/cases/debugger-okay-ignore-try.flags similarity index 100% rename from tests/functional/repl/debugger-okay-ignore-try.flags rename to tests/functional/suites/repl/cases/debugger-okay-ignore-try.flags diff --git a/tests/functional/repl/debugger-okay-ignore-try.in b/tests/functional/suites/repl/cases/debugger-okay-ignore-try.in similarity index 100% rename from tests/functional/repl/debugger-okay-ignore-try.in rename to tests/functional/suites/repl/cases/debugger-okay-ignore-try.in diff --git a/tests/functional/repl/debugger-okay-ignore-try.in.debugexpr.nix b/tests/functional/suites/repl/cases/debugger-okay-ignore-try.in.debugexpr.nix similarity index 100% rename from tests/functional/repl/debugger-okay-ignore-try.in.debugexpr.nix rename to tests/functional/suites/repl/cases/debugger-okay-ignore-try.in.debugexpr.nix diff --git a/tests/functional/repl/debugger-okay-on-warn.expected b/tests/functional/suites/repl/cases/debugger-okay-on-warn.expected similarity index 80% rename from tests/functional/repl/debugger-okay-on-warn.expected rename to tests/functional/suites/repl/cases/debugger-okay-on-warn.expected index 53fb13112522..37a253df5ddd 100644 --- a/tests/functional/repl/debugger-okay-on-warn.expected +++ b/tests/functional/suites/repl/cases/debugger-okay-on-warn.expected @@ -5,7 +5,7 @@ Type :? for help. nix-repl> :p fails error: … while calling the 'throw' builtin - at /path/to/tests/functional/repl/debugger-okay-on-warn.in.debugexpr.nix:3:11: + at /path/to/repl/suite/cases/debugger-okay-on-warn.in.debugexpr.nix:3:11: 2| msg = "hello"; 3| fails = throw (toString 1); | ^ diff --git a/tests/functional/repl/debugger-okay-on-warn.flags b/tests/functional/suites/repl/cases/debugger-okay-on-warn.flags similarity index 100% rename from tests/functional/repl/debugger-okay-on-warn.flags rename to tests/functional/suites/repl/cases/debugger-okay-on-warn.flags diff --git a/tests/functional/repl/debugger-okay-on-warn.in b/tests/functional/suites/repl/cases/debugger-okay-on-warn.in similarity index 100% rename from tests/functional/repl/debugger-okay-on-warn.in rename to tests/functional/suites/repl/cases/debugger-okay-on-warn.in diff --git a/tests/functional/repl/debugger-okay-on-warn.in.debugexpr.nix b/tests/functional/suites/repl/cases/debugger-okay-on-warn.in.debugexpr.nix similarity index 100% rename from tests/functional/repl/debugger-okay-on-warn.in.debugexpr.nix rename to tests/functional/suites/repl/cases/debugger-okay-on-warn.in.debugexpr.nix diff --git a/tests/functional/repl/doc-comment-curried-args.expected b/tests/functional/suites/repl/cases/doc-comment-curried-args.expected similarity index 84% rename from tests/functional/repl/doc-comment-curried-args.expected rename to tests/functional/suites/repl/cases/doc-comment-curried-args.expected index 29ca40cee2cc..ab6a8e18f991 100644 --- a/tests/functional/repl/doc-comment-curried-args.expected +++ b/tests/functional/suites/repl/cases/doc-comment-curried-args.expected @@ -7,7 +7,7 @@ compact, constant, curriedArgs, documentedFormals, floatedIn, lib, measurement, nix-repl> :doc curriedArgs Function `curriedArgs`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:87:5 + … defined at /path/to/repl/suite/cases/doc-comments.nix:87:5 A documented function. @@ -19,7 +19,7 @@ nix-repl> "Note that users may not expect this to behave as it currently does" nix-repl> :doc x Function `curriedArgs`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:91:5 + … defined at /path/to/repl/suite/cases/doc-comments.nix:91:5 The function returned by applying once diff --git a/tests/functional/repl/doc-comment-curried-args.in b/tests/functional/suites/repl/cases/doc-comment-curried-args.in similarity index 100% rename from tests/functional/repl/doc-comment-curried-args.in rename to tests/functional/suites/repl/cases/doc-comment-curried-args.in diff --git a/tests/functional/repl/doc-comment-formals.expected b/tests/functional/suites/repl/cases/doc-comment-formals.expected similarity index 84% rename from tests/functional/repl/doc-comment-formals.expected rename to tests/functional/suites/repl/cases/doc-comment-formals.expected index 65fbc2bd5d80..b94e8763c293 100644 --- a/tests/functional/repl/doc-comment-formals.expected +++ b/tests/functional/suites/repl/cases/doc-comment-formals.expected @@ -10,7 +10,7 @@ nix-repl> "Note that this is not yet complete" nix-repl> :doc documentedFormals Function `documentedFormals`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:104:5 + … defined at /path/to/repl/suite/cases/doc-comments.nix:104:5 Finds x diff --git a/tests/functional/repl/doc-comment-formals.in b/tests/functional/suites/repl/cases/doc-comment-formals.in similarity index 100% rename from tests/functional/repl/doc-comment-formals.in rename to tests/functional/suites/repl/cases/doc-comment-formals.in diff --git a/tests/functional/repl/doc-comment-function.expected b/tests/functional/suites/repl/cases/doc-comment-function.expected similarity index 64% rename from tests/functional/repl/doc-comment-function.expected rename to tests/functional/suites/repl/cases/doc-comment-function.expected index 030cfc3265a1..84b2c1826a65 100644 --- a/tests/functional/repl/doc-comment-function.expected +++ b/tests/functional/suites/repl/cases/doc-comment-function.expected @@ -2,7 +2,7 @@ Nix Type :? for help. nix-repl> :doc import ./doc-comment-function.nix -Function defined at /path/to/tests/functional/repl/doc-comment-function.nix:4:1 +Function defined at /path/to/repl/suite/cases/doc-comment-function.nix:4:1 A doc comment for a file that only contains a function diff --git a/tests/functional/repl/doc-comment-function.in b/tests/functional/suites/repl/cases/doc-comment-function.in similarity index 100% rename from tests/functional/repl/doc-comment-function.in rename to tests/functional/suites/repl/cases/doc-comment-function.in diff --git a/tests/functional/repl/doc-comment-function.nix b/tests/functional/suites/repl/cases/doc-comment-function.nix similarity index 100% rename from tests/functional/repl/doc-comment-function.nix rename to tests/functional/suites/repl/cases/doc-comment-function.nix diff --git a/tests/functional/repl/doc-comments.nix b/tests/functional/suites/repl/cases/doc-comments.nix similarity index 100% rename from tests/functional/repl/doc-comments.nix rename to tests/functional/suites/repl/cases/doc-comments.nix diff --git a/tests/functional/repl/doc-compact.expected b/tests/functional/suites/repl/cases/doc-compact.expected similarity index 80% rename from tests/functional/repl/doc-compact.expected rename to tests/functional/suites/repl/cases/doc-compact.expected index 9fcf6169a5fc..1a46c65a71c6 100644 --- a/tests/functional/repl/doc-compact.expected +++ b/tests/functional/suites/repl/cases/doc-compact.expected @@ -7,7 +7,7 @@ compact, constant, curriedArgs, documentedFormals, floatedIn, lib, measurement, nix-repl> :doc compact Function `compact`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:27:5 + … defined at /path/to/repl/suite/cases/doc-comments.nix:27:5 boom diff --git a/tests/functional/repl/doc-compact.in b/tests/functional/suites/repl/cases/doc-compact.in similarity index 100% rename from tests/functional/repl/doc-compact.in rename to tests/functional/suites/repl/cases/doc-compact.in diff --git a/tests/functional/repl/doc-constant.expected b/tests/functional/suites/repl/cases/doc-constant.expected similarity index 81% rename from tests/functional/repl/doc-constant.expected rename to tests/functional/suites/repl/cases/doc-constant.expected index e2ccd0945080..f57ab7ac425e 100644 --- a/tests/functional/repl/doc-constant.expected +++ b/tests/functional/suites/repl/cases/doc-constant.expected @@ -11,7 +11,7 @@ error: value does not have documentation nix-repl> :doc lib.version Attribute `version` - … defined at /path/to/tests/functional/repl/doc-comments.nix:47:3 + … defined at /path/to/repl/suite/cases/doc-comments.nix:47:3 Immovably fixed. @@ -19,7 +19,7 @@ Immovably fixed. nix-repl> :doc lib.attr.empty Attribute `empty` - … defined at /path/to/tests/functional/repl/doc-comments.nix:52:3 + … defined at /path/to/repl/suite/cases/doc-comments.nix:52:3 Unchangeably constant. @@ -32,7 +32,7 @@ error: | ^ … from the definition of 'attr' - at /path/to/tests/functional/repl/doc-comments.nix:52:3: + at /path/to/repl/suite/cases/doc-comments.nix:52:3: 51| */ 52| lib.attr.empty = { }; | ^ @@ -44,7 +44,7 @@ error: nix-repl> :doc (import ./doc-comments.nix).constant Attribute `constant` - … defined at /path/to/tests/functional/repl/doc-comments.nix:42:3 + … defined at /path/to/repl/suite/cases/doc-comments.nix:42:3 Firmly rigid. @@ -52,7 +52,7 @@ Firmly rigid. nix-repl> :doc (import ./doc-comments.nix).lib.version Attribute `version` - … defined at /path/to/tests/functional/repl/doc-comments.nix:47:3 + … defined at /path/to/repl/suite/cases/doc-comments.nix:47:3 Immovably fixed. @@ -60,7 +60,7 @@ Immovably fixed. nix-repl> :doc (import ./doc-comments.nix).lib.attr.empty Attribute `empty` - … defined at /path/to/tests/functional/repl/doc-comments.nix:52:3 + … defined at /path/to/repl/suite/cases/doc-comments.nix:52:3 Unchangeably constant. @@ -68,7 +68,7 @@ Unchangeably constant. nix-repl> :doc (import ./doc-comments.nix).lib.attr.undocumented Attribute `undocumented` - … defined at /path/to/tests/functional/repl/doc-comments.nix:54:3 + … defined at /path/to/repl/suite/cases/doc-comments.nix:54:3 No documentation found. @@ -116,7 +116,7 @@ error: | ^ … from the definition of 'attr' - at /path/to/tests/functional/repl/doc-comments.nix:52:3: + at /path/to/repl/suite/cases/doc-comments.nix:52:3: 51| */ 52| lib.attr.empty = { }; | ^ diff --git a/tests/functional/repl/doc-constant.in b/tests/functional/suites/repl/cases/doc-constant.in similarity index 100% rename from tests/functional/repl/doc-constant.in rename to tests/functional/suites/repl/cases/doc-constant.in diff --git a/tests/functional/repl/doc-floatedIn.expected b/tests/functional/suites/repl/cases/doc-floatedIn.expected similarity index 80% rename from tests/functional/repl/doc-floatedIn.expected rename to tests/functional/suites/repl/cases/doc-floatedIn.expected index e01f8868ee7b..8baa7ba37f6c 100644 --- a/tests/functional/repl/doc-floatedIn.expected +++ b/tests/functional/suites/repl/cases/doc-floatedIn.expected @@ -7,7 +7,7 @@ compact, constant, curriedArgs, documentedFormals, floatedIn, lib, measurement, nix-repl> :doc floatedIn Function `floatedIn`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:21:5 + … defined at /path/to/repl/suite/cases/doc-comments.nix:21:5 This also works. diff --git a/tests/functional/repl/doc-floatedIn.in b/tests/functional/suites/repl/cases/doc-floatedIn.in similarity index 100% rename from tests/functional/repl/doc-floatedIn.in rename to tests/functional/suites/repl/cases/doc-floatedIn.in diff --git a/tests/functional/repl/doc-functor.expected b/tests/functional/suites/repl/cases/doc-functor.expected similarity index 71% rename from tests/functional/repl/doc-functor.expected rename to tests/functional/suites/repl/cases/doc-functor.expected index e5984098c344..0a81c0f67fea 100644 --- a/tests/functional/repl/doc-functor.expected +++ b/tests/functional/suites/repl/cases/doc-functor.expected @@ -7,21 +7,21 @@ diverging, doubler, helper, helper2, helper3, lib, makeOverridable, makeVeryOver nix-repl> :doc multiplier Function `__functor`\ - … defined at /path/to/tests/functional/repl/doc-functor.nix:12:23 + … defined at /path/to/repl/suite/cases/doc-functor.nix:12:23 Multiply the argument by the factor stored in the factor attribute. nix-repl> :doc doubler Function `multiply`\ - … defined at /path/to/tests/functional/repl/doc-functor.nix:5:17 + … defined at /path/to/repl/suite/cases/doc-functor.nix:5:17 Look, it's just like a function! nix-repl> :doc recursive Function `__functor`\ - … defined at /path/to/tests/functional/repl/doc-functor.nix:82:23 + … defined at /path/to/repl/suite/cases/doc-functor.nix:82:23 This looks bad, but the docs are ok because of the eta expansion. @@ -31,14 +31,14 @@ error: … while partially calling '__functor' to retrieve documentation … while calling '__functor' - at /path/to/tests/functional/repl/doc-functor.nix:90:17: + at /path/to/repl/suite/cases/doc-functor.nix:90:17: 89| */ 90| __functor = self: self.__functor self; | ^ 91| }; … from call site - at /path/to/tests/functional/repl/doc-functor.nix:90:23: + at /path/to/repl/suite/cases/doc-functor.nix:90:23: 89| */ 90| __functor = self: self.__functor self; | ^ @@ -47,7 +47,7 @@ error: (199 duplicate frames omitted) error: stack overflow; max-call-depth exceeded - at /path/to/tests/functional/repl/doc-functor.nix:90:23: + at /path/to/repl/suite/cases/doc-functor.nix:90:23: 89| */ 90| __functor = self: self.__functor self; | ^ @@ -60,14 +60,14 @@ error: (100 duplicate frames omitted) … while calling '__functor' - at /path/to/tests/functional/repl/doc-functor.nix:103:21: + at /path/to/repl/suite/cases/doc-functor.nix:103:21: 102| f = x: { 103| __functor = self: (f (x + 1)); | ^ 104| }; error: stack overflow; max-call-depth exceeded - at /path/to/tests/functional/repl/doc-functor.nix:103:28: + at /path/to/repl/suite/cases/doc-functor.nix:103:28: 102| f = x: { 103| __functor = self: (f (x + 1)); | ^ @@ -75,28 +75,28 @@ error: nix-repl> :doc helper Function `square`\ - … defined at /path/to/tests/functional/repl/doc-functor.nix:36:12 + … defined at /path/to/repl/suite/cases/doc-functor.nix:36:12 Compute x^2 nix-repl> :doc helper2 Function `__functor`\ - … defined at /path/to/tests/functional/repl/doc-functor.nix:46:13 + … defined at /path/to/repl/suite/cases/doc-functor.nix:46:13 This is a function that can be overridden. nix-repl> :doc lib.helper3 Function `__functor`\ - … defined at /path/to/tests/functional/repl/doc-functor.nix:46:13 + … defined at /path/to/repl/suite/cases/doc-functor.nix:46:13 This is a function that can be overridden. nix-repl> :doc helper3 Function `__functor`\ - … defined at /path/to/tests/functional/repl/doc-functor.nix:46:13 + … defined at /path/to/repl/suite/cases/doc-functor.nix:46:13 This is a function that can be overridden. diff --git a/tests/functional/repl/doc-functor.flags b/tests/functional/suites/repl/cases/doc-functor.flags similarity index 100% rename from tests/functional/repl/doc-functor.flags rename to tests/functional/suites/repl/cases/doc-functor.flags diff --git a/tests/functional/repl/doc-functor.in b/tests/functional/suites/repl/cases/doc-functor.in similarity index 100% rename from tests/functional/repl/doc-functor.in rename to tests/functional/suites/repl/cases/doc-functor.in diff --git a/tests/functional/repl/doc-functor.nix b/tests/functional/suites/repl/cases/doc-functor.nix similarity index 100% rename from tests/functional/repl/doc-functor.nix rename to tests/functional/suites/repl/cases/doc-functor.nix diff --git a/tests/functional/repl/doc-lambda-flavors.expected b/tests/functional/suites/repl/cases/doc-lambda-flavors.expected similarity index 67% rename from tests/functional/repl/doc-lambda-flavors.expected rename to tests/functional/suites/repl/cases/doc-lambda-flavors.expected index 676ef73135dd..d1d30ed1ab3b 100644 --- a/tests/functional/repl/doc-lambda-flavors.expected +++ b/tests/functional/suites/repl/cases/doc-lambda-flavors.expected @@ -7,28 +7,28 @@ compact, constant, curriedArgs, documentedFormals, floatedIn, lib, measurement, nix-repl> :doc nonStrict Function `nonStrict`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:60:5 + … defined at /path/to/repl/suite/cases/doc-comments.nix:60:5 My syntax is not strict, but I'm strict anyway. nix-repl> :doc strict Function `strict`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:65:5 + … defined at /path/to/repl/suite/cases/doc-comments.nix:65:5 I don't have to be strict, but I am anyway. nix-repl> :doc strictPre Function `strictPre`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:71:5 + … defined at /path/to/repl/suite/cases/doc-comments.nix:71:5 Here's one way to do this nix-repl> :doc strictPost Function `strictPost`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:76:5 + … defined at /path/to/repl/suite/cases/doc-comments.nix:76:5 Here's another way to do this diff --git a/tests/functional/repl/doc-lambda-flavors.in b/tests/functional/suites/repl/cases/doc-lambda-flavors.in similarity index 100% rename from tests/functional/repl/doc-lambda-flavors.in rename to tests/functional/suites/repl/cases/doc-lambda-flavors.in diff --git a/tests/functional/repl/doc-measurement.expected b/tests/functional/suites/repl/cases/doc-measurement.expected similarity index 81% rename from tests/functional/repl/doc-measurement.expected rename to tests/functional/suites/repl/cases/doc-measurement.expected index ef176cea883f..ac670b5e7ae2 100644 --- a/tests/functional/repl/doc-measurement.expected +++ b/tests/functional/suites/repl/cases/doc-measurement.expected @@ -7,7 +7,7 @@ compact, constant, curriedArgs, documentedFormals, floatedIn, lib, measurement, nix-repl> :doc measurement Function `measurement`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:15:17 + … defined at /path/to/repl/suite/cases/doc-comments.nix:15:17 👈 precisely this wide 👉 diff --git a/tests/functional/repl/doc-measurement.in b/tests/functional/suites/repl/cases/doc-measurement.in similarity index 100% rename from tests/functional/repl/doc-measurement.in rename to tests/functional/suites/repl/cases/doc-measurement.in diff --git a/tests/functional/repl/doc-multiply.expected b/tests/functional/suites/repl/cases/doc-multiply.expected similarity index 84% rename from tests/functional/repl/doc-multiply.expected rename to tests/functional/suites/repl/cases/doc-multiply.expected index c2024b094918..b33e900995d1 100644 --- a/tests/functional/repl/doc-multiply.expected +++ b/tests/functional/suites/repl/cases/doc-multiply.expected @@ -7,7 +7,7 @@ compact, constant, curriedArgs, documentedFormals, floatedIn, lib, measurement, nix-repl> :doc multiply Function `multiply`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:10:14 + … defined at /path/to/repl/suite/cases/doc-comments.nix:10:14 Perform *arithmetic* multiplication. It's kind of like repeated **addition**, very neat. diff --git a/tests/functional/repl/doc-multiply.in b/tests/functional/suites/repl/cases/doc-multiply.in similarity index 100% rename from tests/functional/repl/doc-multiply.in rename to tests/functional/suites/repl/cases/doc-multiply.in diff --git a/tests/functional/repl/doc-unambiguous.expected b/tests/functional/suites/repl/cases/doc-unambiguous.expected similarity index 80% rename from tests/functional/repl/doc-unambiguous.expected rename to tests/functional/suites/repl/cases/doc-unambiguous.expected index d2a452ba7bf3..66e9235b4ede 100644 --- a/tests/functional/repl/doc-unambiguous.expected +++ b/tests/functional/suites/repl/cases/doc-unambiguous.expected @@ -7,7 +7,7 @@ compact, constant, curriedArgs, documentedFormals, floatedIn, lib, measurement, nix-repl> :doc unambiguous Function `unambiguous`\ - … defined at /path/to/tests/functional/repl/doc-comments.nix:37:5 + … defined at /path/to/repl/suite/cases/doc-comments.nix:37:5 Very close diff --git a/tests/functional/repl/doc-unambiguous.in b/tests/functional/suites/repl/cases/doc-unambiguous.in similarity index 100% rename from tests/functional/repl/doc-unambiguous.in rename to tests/functional/suites/repl/cases/doc-unambiguous.in diff --git a/tests/functional/repl/dollar-escaping.expected b/tests/functional/suites/repl/cases/dollar-escaping.expected similarity index 100% rename from tests/functional/repl/dollar-escaping.expected rename to tests/functional/suites/repl/cases/dollar-escaping.expected diff --git a/tests/functional/repl/dollar-escaping.in b/tests/functional/suites/repl/cases/dollar-escaping.in similarity index 100% rename from tests/functional/repl/dollar-escaping.in rename to tests/functional/suites/repl/cases/dollar-escaping.in diff --git a/tests/functional/repl/file-a.nix b/tests/functional/suites/repl/cases/file-a.nix similarity index 100% rename from tests/functional/repl/file-a.nix rename to tests/functional/suites/repl/cases/file-a.nix diff --git a/tests/functional/repl/file-b.nix b/tests/functional/suites/repl/cases/file-b.nix similarity index 100% rename from tests/functional/repl/file-b.nix rename to tests/functional/suites/repl/cases/file-b.nix diff --git a/tests/functional/repl/inherit-and-assignment.expected b/tests/functional/suites/repl/cases/inherit-and-assignment.expected similarity index 100% rename from tests/functional/repl/inherit-and-assignment.expected rename to tests/functional/suites/repl/cases/inherit-and-assignment.expected diff --git a/tests/functional/repl/inherit-and-assignment.in b/tests/functional/suites/repl/cases/inherit-and-assignment.in similarity index 100% rename from tests/functional/repl/inherit-and-assignment.in rename to tests/functional/suites/repl/cases/inherit-and-assignment.in diff --git a/tests/functional/repl/inherit-current-scope.expected b/tests/functional/suites/repl/cases/inherit-current-scope.expected similarity index 100% rename from tests/functional/repl/inherit-current-scope.expected rename to tests/functional/suites/repl/cases/inherit-current-scope.expected diff --git a/tests/functional/repl/inherit-current-scope.in b/tests/functional/suites/repl/cases/inherit-current-scope.in similarity index 100% rename from tests/functional/repl/inherit-current-scope.in rename to tests/functional/suites/repl/cases/inherit-current-scope.in diff --git a/tests/functional/repl/inherit-missing-shows-pos.expected b/tests/functional/suites/repl/cases/inherit-missing-shows-pos.expected similarity index 100% rename from tests/functional/repl/inherit-missing-shows-pos.expected rename to tests/functional/suites/repl/cases/inherit-missing-shows-pos.expected diff --git a/tests/functional/repl/inherit-missing-shows-pos.in b/tests/functional/suites/repl/cases/inherit-missing-shows-pos.in similarity index 100% rename from tests/functional/repl/inherit-missing-shows-pos.in rename to tests/functional/suites/repl/cases/inherit-missing-shows-pos.in diff --git a/tests/functional/repl/inherit-multiple-attrs.expected b/tests/functional/suites/repl/cases/inherit-multiple-attrs.expected similarity index 100% rename from tests/functional/repl/inherit-multiple-attrs.expected rename to tests/functional/suites/repl/cases/inherit-multiple-attrs.expected diff --git a/tests/functional/repl/inherit-multiple-attrs.in b/tests/functional/suites/repl/cases/inherit-multiple-attrs.in similarity index 100% rename from tests/functional/repl/inherit-multiple-attrs.in rename to tests/functional/suites/repl/cases/inherit-multiple-attrs.in diff --git a/tests/functional/repl/inherit-with-semicolon.expected b/tests/functional/suites/repl/cases/inherit-with-semicolon.expected similarity index 100% rename from tests/functional/repl/inherit-with-semicolon.expected rename to tests/functional/suites/repl/cases/inherit-with-semicolon.expected diff --git a/tests/functional/repl/inherit-with-semicolon.in b/tests/functional/suites/repl/cases/inherit-with-semicolon.in similarity index 100% rename from tests/functional/repl/inherit-with-semicolon.in rename to tests/functional/suites/repl/cases/inherit-with-semicolon.in diff --git a/tests/functional/repl/inherit.expected b/tests/functional/suites/repl/cases/inherit.expected similarity index 100% rename from tests/functional/repl/inherit.expected rename to tests/functional/suites/repl/cases/inherit.expected diff --git a/tests/functional/repl/inherit.in b/tests/functional/suites/repl/cases/inherit.in similarity index 100% rename from tests/functional/repl/inherit.in rename to tests/functional/suites/repl/cases/inherit.in diff --git a/tests/functional/repl/list-loaded-nothing-loaded.expected b/tests/functional/suites/repl/cases/list-loaded-nothing-loaded.expected similarity index 100% rename from tests/functional/repl/list-loaded-nothing-loaded.expected rename to tests/functional/suites/repl/cases/list-loaded-nothing-loaded.expected diff --git a/tests/functional/repl/list-loaded-nothing-loaded.in b/tests/functional/suites/repl/cases/list-loaded-nothing-loaded.in similarity index 100% rename from tests/functional/repl/list-loaded-nothing-loaded.in rename to tests/functional/suites/repl/cases/list-loaded-nothing-loaded.in diff --git a/tests/functional/repl/load-and-reload.expected b/tests/functional/suites/repl/cases/load-and-reload.expected similarity index 75% rename from tests/functional/repl/load-and-reload.expected rename to tests/functional/suites/repl/cases/load-and-reload.expected index 7f953e28613a..5d7f8f83648d 100644 --- a/tests/functional/repl/load-and-reload.expected +++ b/tests/functional/suites/repl/cases/load-and-reload.expected @@ -6,12 +6,12 @@ Added 3 variables. fromB, fromBFails, funcFromB nix-repl> :l ./does-not-exist.nix -error: path '/path/to/tests/functional/repl/does-not-exist.nix' does not exist +error: path '/path/to/repl/suite/cases/does-not-exist.nix' does not exist nix-repl> :p fromBFails error: … while calling the 'throw' builtin - at /path/to/tests/functional/repl/file-b.nix:2:16: + at /path/to/repl/suite/cases/file-b.nix:2:16: 1| { 2| fromBFails = throw "b"; | ^ @@ -21,7 +21,7 @@ error: nix-repl> :doc funcFromB Function `funcFromB`\ - … defined at /path/to/tests/functional/repl/file-b.nix:7:15 + … defined at /path/to/repl/suite/cases/file-b.nix:7:15 Some documentation. diff --git a/tests/functional/repl/load-and-reload.in b/tests/functional/suites/repl/cases/load-and-reload.in similarity index 100% rename from tests/functional/repl/load-and-reload.in rename to tests/functional/suites/repl/cases/load-and-reload.in diff --git a/tests/functional/repl/missing-attr-shows-def.expected b/tests/functional/suites/repl/cases/missing-attr-shows-def.expected similarity index 100% rename from tests/functional/repl/missing-attr-shows-def.expected rename to tests/functional/suites/repl/cases/missing-attr-shows-def.expected diff --git a/tests/functional/repl/missing-attr-shows-def.in b/tests/functional/suites/repl/cases/missing-attr-shows-def.in similarity index 100% rename from tests/functional/repl/missing-attr-shows-def.in rename to tests/functional/suites/repl/cases/missing-attr-shows-def.in diff --git a/tests/functional/repl/multiline-string-binding.expected b/tests/functional/suites/repl/cases/multiline-string-binding.expected similarity index 100% rename from tests/functional/repl/multiline-string-binding.expected rename to tests/functional/suites/repl/cases/multiline-string-binding.expected diff --git a/tests/functional/repl/multiline-string-binding.in b/tests/functional/suites/repl/cases/multiline-string-binding.in similarity index 100% rename from tests/functional/repl/multiline-string-binding.in rename to tests/functional/suites/repl/cases/multiline-string-binding.in diff --git a/tests/functional/repl/multiline-string-function-binding.expected b/tests/functional/suites/repl/cases/multiline-string-function-binding.expected similarity index 100% rename from tests/functional/repl/multiline-string-function-binding.expected rename to tests/functional/suites/repl/cases/multiline-string-function-binding.expected diff --git a/tests/functional/repl/multiline-string-function-binding.in b/tests/functional/suites/repl/cases/multiline-string-function-binding.in similarity index 100% rename from tests/functional/repl/multiline-string-function-binding.in rename to tests/functional/suites/repl/cases/multiline-string-function-binding.in diff --git a/tests/functional/repl/multiple-bindings-same-line.expected b/tests/functional/suites/repl/cases/multiple-bindings-same-line.expected similarity index 100% rename from tests/functional/repl/multiple-bindings-same-line.expected rename to tests/functional/suites/repl/cases/multiple-bindings-same-line.expected diff --git a/tests/functional/repl/multiple-bindings-same-line.in b/tests/functional/suites/repl/cases/multiple-bindings-same-line.in similarity index 100% rename from tests/functional/repl/multiple-bindings-same-line.in rename to tests/functional/suites/repl/cases/multiple-bindings-same-line.in diff --git a/tests/functional/repl/nested-attr-path.expected b/tests/functional/suites/repl/cases/nested-attr-path.expected similarity index 100% rename from tests/functional/repl/nested-attr-path.expected rename to tests/functional/suites/repl/cases/nested-attr-path.expected diff --git a/tests/functional/repl/nested-attr-path.in b/tests/functional/suites/repl/cases/nested-attr-path.in similarity index 100% rename from tests/functional/repl/nested-attr-path.in rename to tests/functional/suites/repl/cases/nested-attr-path.in diff --git a/tests/functional/repl/pretty-print-idempotent.expected b/tests/functional/suites/repl/cases/pretty-print-idempotent.expected similarity index 100% rename from tests/functional/repl/pretty-print-idempotent.expected rename to tests/functional/suites/repl/cases/pretty-print-idempotent.expected diff --git a/tests/functional/repl/pretty-print-idempotent.in b/tests/functional/suites/repl/cases/pretty-print-idempotent.in similarity index 100% rename from tests/functional/repl/pretty-print-idempotent.in rename to tests/functional/suites/repl/cases/pretty-print-idempotent.in diff --git a/tests/functional/repl/pretty-print-idempotent.nix b/tests/functional/suites/repl/cases/pretty-print-idempotent.nix similarity index 100% rename from tests/functional/repl/pretty-print-idempotent.nix rename to tests/functional/suites/repl/cases/pretty-print-idempotent.nix diff --git a/tests/functional/repl/printing.expected b/tests/functional/suites/repl/cases/printing.expected similarity index 100% rename from tests/functional/repl/printing.expected rename to tests/functional/suites/repl/cases/printing.expected diff --git a/tests/functional/repl/printing.in b/tests/functional/suites/repl/cases/printing.in similarity index 100% rename from tests/functional/repl/printing.in rename to tests/functional/suites/repl/cases/printing.in diff --git a/tests/functional/suites/repl/characterisation.sh b/tests/functional/suites/repl/characterisation.sh new file mode 100644 index 000000000000..a3f8ee5849b0 --- /dev/null +++ b/tests/functional/suites/repl/characterisation.sh @@ -0,0 +1,92 @@ +# shellcheck shell=bash +# shellcheck source=/dev/null +# shellcheck disable=SC2034 + +{ set +x; } 2>/dev/null + +source "$_NIX_TEST_SOURCE_DIR"/common/characterisation/framework.sh + +testNumber=0 + +# TODO: Convert all tests using characterisation tests to TAP and move this +# to the framework. + +function skipTest() { + # TAP tests should always exit with 0. + exit 0 +} + +function reportDiffAcceptFailure() { + (( testNumber+=1 )) + local -r testName=$2 + if [[ "${_NIX_TEST_ACCEPT-}" == 1 ]]; then + echo "ok $testNumber $testName # SKIP" + else + echo "not ok $testNumber $testName" + fi + echo "$1" >&2 +} + +function reportDiffAcceptSuccess() { + (( testNumber+=1 )) + echo "ok $testNumber $testName" +} + +testDir=$PWD + +# TODO: move init to characterisation/framework.sh +badDiff=0 +badExitCode=0 + +testCases=( "$testDir"/cases/*.in ) + +echo "TAP version 14" +echo "1..${#testCases[@]}" + +for test in "${testCases[@]}"; do + test="$(basename "$test" .in)" + in="$testDir/cases/$test.in" + actual="$TEST_ROOT/$test.actual" + expected="$testDir/cases/$test.expected" + declare -a flags=() + if test -e "$testDir/cases/$test.flags"; then + read -r -a flags < "$testDir/cases/$test.flags" + fi + + # Allow putting comments (lines starting with `# COM:`) in the test for + # documentation purposes. Regular comments are not skipped, since those are + # also interpreted by the repl. + inputWithoutComments=$(grep -Ev '^[[:space:]]*#[[:space:]]*COM:' "$in") + + if [ -f "$testDir/cases/$test.in.debugexpr.nix" ]; then + if [[ "$test" =~ debugger-fail-.* ]]; then + expectedFail=1 + elif [[ "$test" =~ debugger-okay-.* ]]; then + expectedFail=0 + else + die "unexpected debugger test name: '$test', should be either debugger-okay-* or debugger-fail-*" + fi + + set +e + (cd "$testDir/cases"; set +x; echo "$inputWithoutComments" | runDebugRepl "$testDir/cases/$test.in.debugexpr.nix" "$testDir" "${flags[@]}" 2>&1) > "$actual" + debuggerTestCode=$? + set -e + + if ((expectedFail == 0 && debuggerTestCode != 0)); then + echo "test failed: $test (exit code $debuggerTestCode)" >&2 + badExitCode=1 + elif ((expectedFail == 1 && debuggerTestCode == 0)); then + echo "test failed: $test unexpectedly succeeded" >&2 + badExitCode=1 + fi + else + (cd "$testDir/cases"; set +x; echo "$inputWithoutComments" | runRepl "$testDir" "${flags[@]}" 2>&1) > "$actual" || { + echo "test failed: $test (exit code $?)" >&2 + badExitCode=1 + } + fi + + diffAndAcceptInner "$test" "$actual" "$expected" +done + +characterisationTestExit diff --git a/tests/functional/suites/repl/common.sh b/tests/functional/suites/repl/common.sh new file mode 100644 index 000000000000..a54361e6a093 --- /dev/null +++ b/tests/functional/suites/repl/common.sh @@ -0,0 +1,8 @@ +# shellcheck shell=bash + +{ set +x; } 2>/dev/null + +source "$_NIX_TEST_SOURCE_DIR"/common.sh +source common/functions.sh + +set -x diff --git a/tests/functional/suites/repl/common/functions.sh b/tests/functional/suites/repl/common/functions.sh new file mode 100644 index 000000000000..f615788ddc80 --- /dev/null +++ b/tests/functional/suites/repl/common/functions.sh @@ -0,0 +1,99 @@ +# shellcheck shell=bash + +# Remove ANSI escape sequences. They can prevent grep from finding a match. +stripColors () { + sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' +} + +testReplResponseGeneral () { + local grepMode commands expectedResponse response + grepMode="$1"; shift + commands="$1"; shift + # Expected response can contain newlines. + # grep can't handle multiline patterns, so replace newlines with TEST_NEWLINE + # in both expectedResponse and response. + # awk ORS always adds a trailing record separator, so we strip it with sed. + expectedResponse="$(printf '%s' "$1" | awk 1 ORS=TEST_NEWLINE | sed 's/TEST_NEWLINE$//')"; shift + # We don't need to strip trailing record separator here, since extra data is ok. + response="$(nix repl "$@" <<< "$commands" 2>&1 | stripColors | awk 1 ORS=TEST_NEWLINE)" + printf '%s' "$response" | grepQuiet "$grepMode" -s "$expectedResponse" \ + || fail "$(echo "repl command set: + +$commands + +does not respond with: + +--- +$expectedResponse +--- + +but with: + +--- +$response +--- + +" | sed 's/TEST_NEWLINE/\n/g')" +} + +testReplResponse () { + testReplResponseGeneral --basic-regexp "$@" +} + +testReplResponseNoRegex () { + testReplResponseGeneral --fixed-strings "$@" +} + +nixVersion="$(nix eval --impure --raw --expr 'builtins.nixVersion' --extra-experimental-features nix-command)" + +# TODO: write a repl interacter for testing. Papering over the differences between readline / editline and between platforms is a pain. + +# I couldn't get readline and editline to agree on the newline before the prompt, +# so let's just force it to be one empty line. +stripEmptyLinesBeforePrompt() { + # --null-data: treat input as NUL-terminated instead of newline-terminated + sed --null-data 's/\n\n*nix-repl>/\n\nnix-repl>/g' +} + +# We don't get a final prompt on darwin, so we strip this as well. +stripFinalPrompt() { + # Strip the final prompt and/or any trailing spaces + sed --null-data \ + -e 's/\(.*[^\n]\)\n\n*nix-repl>[ \n]*$/\1/' \ + -e 's/[ \n]*$/\n/' +} + +filterReplOutput () { + # That is right, we are also filtering out the testdir _without underscores_. + # This is crazy, but without it, GHA will fail to run the tests, showing paths + # _with_ underscores in the set -x log, but _without_ underscores in the + # supposed nix repl output. I have looked in a number of places, but I cannot + # find a mechanism that could cause this to happen. + local testDirNoUnderscores + local testDir="$1" + + testDirNoUnderscores="${testDir//_/}" + + stripColors \ + | tr -d '\0' \ + | stripEmptyLinesBeforePrompt \ + | stripFinalPrompt \ + | sed \ + -e "s@$testDir@/path/to/repl/suite@g" \ + -e "s@$testDirNoUnderscores@/path/to/repl/suite@g" \ + -e "s@$nixVersion@@g" \ + | grep -vF $'warning: you don\'t have Internet access; disabling some network-dependent features' \ + ; +} + +runRepl () { + _NIX_TEST_RAW_MARKDOWN=1 \ + _NIX_TEST_REPL_ECHO=1 \ + nix repl "${@:2}" 2>&1 | filterReplOutput "$1" +} + +runDebugRepl () { + _NIX_TEST_RAW_MARKDOWN=1 \ + _NIX_TEST_REPL_ECHO=1 \ + nix eval --file "$1" --debugger "${@:3}" 2>&1 | filterReplOutput "$2" +} diff --git a/tests/functional/suites/repl/edit-builtin-files.sh b/tests/functional/suites/repl/edit-builtin-files.sh new file mode 100644 index 000000000000..3f441a8b701e --- /dev/null +++ b/tests/functional/suites/repl/edit-builtin-files.sh @@ -0,0 +1,4 @@ +# shellcheck shell=bash + +EDITOR='cat' nix repl <<< ':e derivation' 2>&1 | grepQuiet 'derivationStrict' +EDITOR='cat' nix repl <<< ':e ' 2>&1 | grepQuiet 'builtin:fetchurl' diff --git a/tests/functional/suites/repl/function.nix b/tests/functional/suites/repl/function.nix new file mode 100644 index 000000000000..3745ce9a6c70 --- /dev/null +++ b/tests/functional/suites/repl/function.nix @@ -0,0 +1,4 @@ +{ + x ? 1, +}: +import ((builtins.getEnv "_NIX_TEST_SOURCE_DIR") + "/simple.nix") diff --git a/tests/functional/suites/repl/meson.build b/tests/functional/suites/repl/meson.build new file mode 100644 index 000000000000..8c782b361ed1 --- /dev/null +++ b/tests/functional/suites/repl/meson.build @@ -0,0 +1,15 @@ +suites += { + 'name' : 'repl', + 'deps' : [], + 'tests' : [ + 'characterisation.sh', + 'edit-builtin-files.sh', + 'simple.sh', + 'reload-flakes.sh', + ], + 'workdir' : meson.current_source_dir(), + 'env' : {'BASH_ENV' : meson.current_source_dir() / 'common.sh'}, + 'overrides' : { + 'characterisation.sh' : {'protocol' : 'tap'}, + }, +} diff --git a/tests/functional/suites/repl/reload-flakes.sh b/tests/functional/suites/repl/reload-flakes.sh new file mode 100644 index 000000000000..4361bd3b25f4 --- /dev/null +++ b/tests/functional/suites/repl/reload-flakes.sh @@ -0,0 +1,97 @@ +# shellcheck shell=bash + +# shellcheck disable=SC2164 +cd "$TEST_ROOT" + +# Doesn't do much without https://github.com/NixOS/nix/issues/10069 +enableFeatures 'flakes' + +mkdir -p flake && cat < flake/flake.nix +{ + outputs = { self }: { + foo = 1; + bar.baz = 2; + + changingThing = "beforeChange"; + }; +} +EOF + +testReplResponse ' +foo + baz +' "3" ./flake ./flake\#bar + +# Test the `:reload` mechanism with flakes: +# - Eval `./flake#changingThing` +# - Modify the flake +# - Re-eval it +# - Check that the result has changed + +mkfifo repl_fifo +touch repl_output +nix repl ./flake < repl_fifo >> repl_output 2>&1 & +repl_pid=$! +exec 3>repl_fifo # Open fifo for writing +echo "changingThing" >&3 +for i in $(seq 1 1000); do + if grep -q "beforeChange" repl_output; then + break + fi + cat repl_output + sleep 0.1 +done +if [[ "$i" -eq 100 ]]; then + echo "Timed out waiting for beforeChange" + exit 1 +fi + +sed -i 's/beforeChange/afterChange/' flake/flake.nix + +# Send reload and second command +echo ":reload" >&3 +echo "changingThing" >&3 +echo "exit" >&3 +exec 3>&- # Close fifo +wait $repl_pid # Wait for process to finish +grep -q "afterChange" repl_output + +# Regression: `:reload` on a flake loaded from a *git* work tree must pick up +# uncommitted changes. Guards against the per-process workdir-info cache +# pinning the tree to the rev seen on first load. +if [[ $(type -p git) ]]; then + createGitRepo gitflake + cat > gitflake/flake.nix <> repl_output 2>&1 & + repl_pid=$! + exec 3>repl_fifo + echo "changingThing" >&3 + for _ in $(seq 1 1000); do + grep -q "beforeChange" repl_output && break + sleep 0.1 + done + grep -q "beforeChange" repl_output || fail "git flake didn't load" + sed -i 's/beforeChange/afterChange/' gitflake/flake.nix + echo ":reload" >&3 + echo "changingThing" >&3 + echo "exit" >&3 + exec 3>&- + wait $repl_pid + grep -q "afterChange" repl_output || fail ":reload didn't pick up git work tree change" +fi + +# Regression: a failed `:lf` must not be remembered for `:reload`, +# and an error in one loaded file must not drop later ones from the reload list. +testReplResponseNoRegex ' +:lf ./does-not-exist-flake +:lf ./flake +:r +foo +' '1' diff --git a/tests/functional/suites/repl/simple.sh b/tests/functional/suites/repl/simple.sh new file mode 100644 index 000000000000..df53fcf9771e --- /dev/null +++ b/tests/functional/suites/repl/simple.sh @@ -0,0 +1,27 @@ +# shellcheck shell=bash + +testReplResponse ' +drvPath +' '".*-simple.drv"' \ + --file "$_NIX_TEST_SOURCE_DIR/simple.nix" + +testReplResponse ' +drvPath +' '".*-simple.drv"' \ + --file "$_NIX_TEST_SOURCE_DIR/simple.nix" --experimental-features 'ca-derivations' + +# `--file` autocalls, `--expr` does not. +testReplResponse ' +drvPath +' '".*-simple.drv"' \ + --file "./function.nix" + +testReplResponse ' +' 'while evaluating an attribute set to be merged in the global scope' \ + --expr '{ x ? 1 }: import '"$_NIX_TEST_SOURCE_DIR"'/simple.nix' + +# Don't prompt for more input when getting unexpected EOF in imported files. +testReplResponse " +import $_NIX_TEST_SOURCE_DIR/lang/parse-fail-eof-pos.nix +" \ + '.*error: syntax error, unexpected end of file.*'