From c63ba3c485d2ccb6bf623bd8df5cace588a6d58e Mon Sep 17 00:00:00 2001 From: "Commentator2.0" Date: Tue, 13 May 2025 20:54:25 +0200 Subject: [PATCH] tests/functional2/lang: migrated first tests Change-Id: I4b5755a63d9454db20f63f751f5f33564a2ee5be --- tests/functional/lang.sh | 1 - tests/functional/lang/eval-okay-nul.flags | 1 - tests/functional/lang/eval-okay-nul.out.exp | 1 - tests/functional/lang/parse-fail-crlf.nix | 1 - tests/functional/lang/parse-fail-nul.nix | 1 - tests/functional/lang/parse-okay-crlf.flags | 1 - .../eval-fail-1.err.exp} | 4 ++-- .../eval-fail-2.err.exp} | 0 .../eval-fail-3.err.exp} | 4 ++-- .../eval-fail-4.err.exp} | 2 +- .../lang/bad_string_interpolation/in-1.nix} | 0 .../lang/bad_string_interpolation/in-2.nix} | 0 .../lang/bad_string_interpolation/in-3.nix} | 0 .../lang/bad_string_interpolation/in-4.nix} | 0 tests/functional2/lang/err_context/__init__.py | 0 .../lang/err_context/test_err_context.py | 10 ++++++++++ .../lang/import/eval-okay.out.exp} | 0 .../lang/import}/imported.nix | 0 .../lang/import}/imported2.nix | 0 .../lang/import/in.nix} | 0 tests/functional2/lang/import/test.toml | 3 +++ .../lang/line_endings/allow-depr.out.exp} | 0 .../lang/line_endings/depr.err.exp} | 4 ++-- .../lang/line_endings/in.nix} | 0 tests/functional2/lang/line_endings/test.toml | 6 ++++++ .../lang/nul_bytes/eval-allow-depr.out.exp} | 0 .../lang/nul_bytes/eval-depr.err.exp} | Bin 307 -> 296 bytes .../lang/nul_bytes/in.nix} | Bin .../lang/nul_bytes/parse-allow-depr.out.exp | 3 +++ .../lang/nul_bytes/parse-depr.err.exp | Bin 0 -> 296 bytes tests/functional2/lang/nul_bytes/test.toml | 13 +++++++++++++ .../lang/scope/eval-fail-5.err.exp} | 10 +++++----- .../lang/scope/eval-okay-1.out.exp} | 0 .../lang/scope/eval-okay-2.out.exp} | 0 .../lang/scope/eval-okay-3.out.exp} | 0 .../lang/scope/eval-okay-4.out.exp} | 0 .../lang/scope/eval-okay-6.out.exp} | 0 .../lang/scope/eval-okay-7.out.exp} | 0 .../lang/scope/in-1.nix} | 0 .../lang/scope/in-2.nix} | 0 .../lang/scope/in-3.nix} | 0 .../lang/scope/in-4.nix} | 0 .../lang/scope/in-5.nix} | 0 .../lang/scope/in-6.nix} | 0 .../lang/scope/in-7.nix} | 0 .../lang/with/eval-okay.out.exp} | 0 .../lang/with/in.nix} | 0 47 files changed, 47 insertions(+), 18 deletions(-) delete mode 100644 tests/functional/lang/eval-okay-nul.flags delete mode 100644 tests/functional/lang/eval-okay-nul.out.exp delete mode 120000 tests/functional/lang/parse-fail-crlf.nix delete mode 120000 tests/functional/lang/parse-fail-nul.nix delete mode 100644 tests/functional/lang/parse-okay-crlf.flags rename tests/{functional/lang/eval-fail-bad-string-interpolation-1.err.exp => functional2/lang/bad_string_interpolation/eval-fail-1.err.exp} (60%) rename tests/{functional/lang/eval-fail-bad-string-interpolation-2.err.exp => functional2/lang/bad_string_interpolation/eval-fail-2.err.exp} (100%) rename tests/{functional/lang/eval-fail-bad-string-interpolation-3.err.exp => functional2/lang/bad_string_interpolation/eval-fail-3.err.exp} (60%) rename tests/{functional/lang/eval-fail-bad-string-interpolation-4.err.exp => functional2/lang/bad_string_interpolation/eval-fail-4.err.exp} (86%) rename tests/{functional/lang/eval-fail-bad-string-interpolation-1.nix => functional2/lang/bad_string_interpolation/in-1.nix} (100%) rename tests/{functional/lang/eval-fail-bad-string-interpolation-2.nix => functional2/lang/bad_string_interpolation/in-2.nix} (100%) rename tests/{functional/lang/eval-fail-bad-string-interpolation-3.nix => functional2/lang/bad_string_interpolation/in-3.nix} (100%) rename tests/{functional/lang/eval-fail-bad-string-interpolation-4.nix => functional2/lang/bad_string_interpolation/in-4.nix} (100%) create mode 100644 tests/functional2/lang/err_context/__init__.py create mode 100644 tests/functional2/lang/err_context/test_err_context.py rename tests/{functional/lang/eval-okay-import.exp => functional2/lang/import/eval-okay.out.exp} (100%) rename tests/{functional/lang => functional2/lang/import}/imported.nix (100%) rename tests/{functional/lang => functional2/lang/import}/imported2.nix (100%) rename tests/{functional/lang/eval-okay-import.nix => functional2/lang/import/in.nix} (100%) create mode 100644 tests/functional2/lang/import/test.toml rename tests/{functional/lang/parse-okay-crlf.exp => functional2/lang/line_endings/allow-depr.out.exp} (100%) rename tests/{functional/lang/parse-fail-crlf.err.exp => functional2/lang/line_endings/depr.err.exp} (88%) rename tests/{functional/lang/parse-okay-crlf.nix => functional2/lang/line_endings/in.nix} (100%) create mode 100644 tests/functional2/lang/line_endings/test.toml rename tests/{functional/lang/eval-okay-nul.exp => functional2/lang/nul_bytes/eval-allow-depr.out.exp} (100%) rename tests/{functional/lang/parse-fail-nul.err.exp => functional2/lang/nul_bytes/eval-depr.err.exp} (87%) rename tests/{functional/lang/eval-okay-nul.nix => functional2/lang/nul_bytes/in.nix} (100%) create mode 100644 tests/functional2/lang/nul_bytes/parse-allow-depr.out.exp create mode 100644 tests/functional2/lang/nul_bytes/parse-depr.err.exp create mode 100644 tests/functional2/lang/nul_bytes/test.toml rename tests/{functional/lang/eval-fail-scope-5.err.exp => functional2/lang/scope/eval-fail-5.err.exp} (75%) rename tests/{functional/lang/eval-okay-scope-1.exp => functional2/lang/scope/eval-okay-1.out.exp} (100%) rename tests/{functional/lang/eval-okay-scope-2.exp => functional2/lang/scope/eval-okay-2.out.exp} (100%) rename tests/{functional/lang/eval-okay-scope-3.exp => functional2/lang/scope/eval-okay-3.out.exp} (100%) rename tests/{functional/lang/eval-okay-scope-4.exp => functional2/lang/scope/eval-okay-4.out.exp} (100%) rename tests/{functional/lang/eval-okay-scope-6.exp => functional2/lang/scope/eval-okay-6.out.exp} (100%) rename tests/{functional/lang/eval-okay-scope-7.exp => functional2/lang/scope/eval-okay-7.out.exp} (100%) rename tests/{functional/lang/eval-okay-scope-1.nix => functional2/lang/scope/in-1.nix} (100%) rename tests/{functional/lang/eval-okay-scope-2.nix => functional2/lang/scope/in-2.nix} (100%) rename tests/{functional/lang/eval-okay-scope-3.nix => functional2/lang/scope/in-3.nix} (100%) rename tests/{functional/lang/eval-okay-scope-4.nix => functional2/lang/scope/in-4.nix} (100%) rename tests/{functional/lang/eval-fail-scope-5.nix => functional2/lang/scope/in-5.nix} (100%) rename tests/{functional/lang/eval-okay-scope-6.nix => functional2/lang/scope/in-6.nix} (100%) rename tests/{functional/lang/eval-okay-scope-7.nix => functional2/lang/scope/in-7.nix} (100%) rename tests/{functional/lang/eval-okay-with.exp => functional2/lang/with/eval-okay.out.exp} (100%) rename tests/{functional/lang/eval-okay-with.nix => functional2/lang/with/in.nix} (100%) diff --git a/tests/functional/lang.sh b/tests/functional/lang.sh index 8310ac1f6..cac0b896d 100755 --- a/tests/functional/lang.sh +++ b/tests/functional/lang.sh @@ -25,7 +25,6 @@ nix-instantiate --eval -E 'builtins.addErrorContext "Hello" 123' 2>&1 nix-instantiate --trace-verbose --eval -E 'builtins.traceVerbose "Hello" 123' 2>&1 | grepQuiet Hello nix-instantiate --eval -E 'builtins.traceVerbose "Hello" 123' 2>&1 | grepQuietInverse Hello nix-instantiate --show-trace --eval -E 'builtins.addErrorContext "Hello" 123' 2>&1 | grepQuietInverse Hello -expectStderr 1 nix-instantiate --show-trace --eval -E 'builtins.addErrorContext "Hello" (throw "Foo")' | grepQuiet Hello expectStderr 1 nix-instantiate --show-trace --eval -E 'builtins.addErrorContext "Hello %" (throw "Foo")' | grepQuiet 'Hello %' nix-instantiate --eval -E 'let x = builtins.trace { x = x; } true; in x' \ diff --git a/tests/functional/lang/eval-okay-nul.flags b/tests/functional/lang/eval-okay-nul.flags deleted file mode 100644 index 33da0f779..000000000 --- a/tests/functional/lang/eval-okay-nul.flags +++ /dev/null @@ -1 +0,0 @@ ---extra-deprecated-features nul-bytes diff --git a/tests/functional/lang/eval-okay-nul.out.exp b/tests/functional/lang/eval-okay-nul.out.exp deleted file mode 100644 index 257cc5642..000000000 --- a/tests/functional/lang/eval-okay-nul.out.exp +++ /dev/null @@ -1 +0,0 @@ -foo diff --git a/tests/functional/lang/parse-fail-crlf.nix b/tests/functional/lang/parse-fail-crlf.nix deleted file mode 120000 index bcf59ab82..000000000 --- a/tests/functional/lang/parse-fail-crlf.nix +++ /dev/null @@ -1 +0,0 @@ -parse-okay-crlf.nix \ No newline at end of file diff --git a/tests/functional/lang/parse-fail-nul.nix b/tests/functional/lang/parse-fail-nul.nix deleted file mode 120000 index 9b0527d33..000000000 --- a/tests/functional/lang/parse-fail-nul.nix +++ /dev/null @@ -1 +0,0 @@ -eval-okay-nul.nix \ No newline at end of file diff --git a/tests/functional/lang/parse-okay-crlf.flags b/tests/functional/lang/parse-okay-crlf.flags deleted file mode 100644 index a7c7a5cbe..000000000 --- a/tests/functional/lang/parse-okay-crlf.flags +++ /dev/null @@ -1 +0,0 @@ ---extra-deprecated-features cr-line-endings diff --git a/tests/functional/lang/eval-fail-bad-string-interpolation-1.err.exp b/tests/functional2/lang/bad_string_interpolation/eval-fail-1.err.exp similarity index 60% rename from tests/functional/lang/eval-fail-bad-string-interpolation-1.err.exp rename to tests/functional2/lang/bad_string_interpolation/eval-fail-1.err.exp index 7c144c7e2..a9728e8bb 100644 --- a/tests/functional/lang/eval-fail-bad-string-interpolation-1.err.exp +++ b/tests/functional2/lang/bad_string_interpolation/eval-fail-1.err.exp @@ -1,8 +1,8 @@ error: … while evaluating a path segment - at /pwd/eval-fail-bad-string-interpolation-1.nix:1:2: + at /pwd/in.nix:1:2: 1| "${x: x}" | ^ 2| - error: cannot coerce a function to a string: «lambda @ /pwd/eval-fail-bad-string-interpolation-1.nix:1:4» + error: cannot coerce a function to a string: «lambda @ /pwd/in.nix:1:4» diff --git a/tests/functional/lang/eval-fail-bad-string-interpolation-2.err.exp b/tests/functional2/lang/bad_string_interpolation/eval-fail-2.err.exp similarity index 100% rename from tests/functional/lang/eval-fail-bad-string-interpolation-2.err.exp rename to tests/functional2/lang/bad_string_interpolation/eval-fail-2.err.exp diff --git a/tests/functional/lang/eval-fail-bad-string-interpolation-3.err.exp b/tests/functional2/lang/bad_string_interpolation/eval-fail-3.err.exp similarity index 60% rename from tests/functional/lang/eval-fail-bad-string-interpolation-3.err.exp rename to tests/functional2/lang/bad_string_interpolation/eval-fail-3.err.exp index ef79ad2ad..3a1e06e2e 100644 --- a/tests/functional/lang/eval-fail-bad-string-interpolation-3.err.exp +++ b/tests/functional2/lang/bad_string_interpolation/eval-fail-3.err.exp @@ -1,8 +1,8 @@ error: … while evaluating a path segment - at /pwd/eval-fail-bad-string-interpolation-3.nix:1:3: + at /pwd/in.nix:1:3: 1| ''${x: x}'' | ^ 2| - error: cannot coerce a function to a string: «lambda @ /pwd/eval-fail-bad-string-interpolation-3.nix:1:5» + error: cannot coerce a function to a string: «lambda @ /pwd/in.nix:1:5» diff --git a/tests/functional/lang/eval-fail-bad-string-interpolation-4.err.exp b/tests/functional2/lang/bad_string_interpolation/eval-fail-4.err.exp similarity index 86% rename from tests/functional/lang/eval-fail-bad-string-interpolation-4.err.exp rename to tests/functional2/lang/bad_string_interpolation/eval-fail-4.err.exp index bd4dc48ee..555bc7e70 100644 --- a/tests/functional/lang/eval-fail-bad-string-interpolation-4.err.exp +++ b/tests/functional2/lang/bad_string_interpolation/eval-fail-4.err.exp @@ -1,6 +1,6 @@ error: … while evaluating a path segment - at /pwd/eval-fail-bad-string-interpolation-4.nix:9:3: + at /pwd/in.nix:9:3: 8| # The error message should not be too long. 9| ''${pkgs}'' | ^ diff --git a/tests/functional/lang/eval-fail-bad-string-interpolation-1.nix b/tests/functional2/lang/bad_string_interpolation/in-1.nix similarity index 100% rename from tests/functional/lang/eval-fail-bad-string-interpolation-1.nix rename to tests/functional2/lang/bad_string_interpolation/in-1.nix diff --git a/tests/functional/lang/eval-fail-bad-string-interpolation-2.nix b/tests/functional2/lang/bad_string_interpolation/in-2.nix similarity index 100% rename from tests/functional/lang/eval-fail-bad-string-interpolation-2.nix rename to tests/functional2/lang/bad_string_interpolation/in-2.nix diff --git a/tests/functional/lang/eval-fail-bad-string-interpolation-3.nix b/tests/functional2/lang/bad_string_interpolation/in-3.nix similarity index 100% rename from tests/functional/lang/eval-fail-bad-string-interpolation-3.nix rename to tests/functional2/lang/bad_string_interpolation/in-3.nix diff --git a/tests/functional/lang/eval-fail-bad-string-interpolation-4.nix b/tests/functional2/lang/bad_string_interpolation/in-4.nix similarity index 100% rename from tests/functional/lang/eval-fail-bad-string-interpolation-4.nix rename to tests/functional2/lang/bad_string_interpolation/in-4.nix diff --git a/tests/functional2/lang/err_context/__init__.py b/tests/functional2/lang/err_context/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/functional2/lang/err_context/test_err_context.py b/tests/functional2/lang/err_context/test_err_context.py new file mode 100644 index 000000000..380b8b09d --- /dev/null +++ b/tests/functional2/lang/err_context/test_err_context.py @@ -0,0 +1,10 @@ +from functional2.testlib.fixtures.nix import Nix + + +def test_err_context(nix: Nix): + # the lang test framework doesn't check this folder, as there is a custom test in here + # it won't scream about missing an `in.nix` or .exp files + result = nix.nix_instantiate( + ["--show-trace", "--eval", "-E", 'builtins.addErrorContext "Hello" (throw "Foo")'] + ).run() + assert "Hello" in result.expect(1).stderr_s diff --git a/tests/functional/lang/eval-okay-import.exp b/tests/functional2/lang/import/eval-okay.out.exp similarity index 100% rename from tests/functional/lang/eval-okay-import.exp rename to tests/functional2/lang/import/eval-okay.out.exp diff --git a/tests/functional/lang/imported.nix b/tests/functional2/lang/import/imported.nix similarity index 100% rename from tests/functional/lang/imported.nix rename to tests/functional2/lang/import/imported.nix diff --git a/tests/functional/lang/imported2.nix b/tests/functional2/lang/import/imported2.nix similarity index 100% rename from tests/functional/lang/imported2.nix rename to tests/functional2/lang/import/imported2.nix diff --git a/tests/functional/lang/eval-okay-import.nix b/tests/functional2/lang/import/in.nix similarity index 100% rename from tests/functional/lang/eval-okay-import.nix rename to tests/functional2/lang/import/in.nix diff --git a/tests/functional2/lang/import/test.toml b/tests/functional2/lang/import/test.toml new file mode 100644 index 000000000..4c9e923e2 --- /dev/null +++ b/tests/functional2/lang/import/test.toml @@ -0,0 +1,3 @@ +[eval-okay] +runner = "eval-okay" +extra-files = ["imported.nix", "imported2.nix"] diff --git a/tests/functional/lang/parse-okay-crlf.exp b/tests/functional2/lang/line_endings/allow-depr.out.exp similarity index 100% rename from tests/functional/lang/parse-okay-crlf.exp rename to tests/functional2/lang/line_endings/allow-depr.out.exp diff --git a/tests/functional/lang/parse-fail-crlf.err.exp b/tests/functional2/lang/line_endings/depr.err.exp similarity index 88% rename from tests/functional/lang/parse-fail-crlf.err.exp rename to tests/functional2/lang/line_endings/depr.err.exp index 06c375774..f6ca6b19a 100644 --- a/tests/functional/lang/parse-fail-crlf.err.exp +++ b/tests/functional2/lang/line_endings/depr.err.exp @@ -1,11 +1,11 @@ warning: CR (`\r`) and CRLF (`\r\n`) line endings are not supported. Please inspect the file and normalize it to use LF (`\n`) line endings instead. Use --extra-deprecated-features cr-line-endings to silence this warning. - at /pwd/parse-okay-crlf.nix:7:21: + at /pwd/in.nix:7:21: 6| x = 7| # Dit is een test. | ^ 8| y; error: CR (`\r`) and CRLF (`\r\n`) line endings are not supported. Please inspect the file and normalize it to use LF (`\n`) line endings instead. Use --extra-deprecated-features cr-line-endings to silence this warning. - at /pwd/parse-okay-crlf.nix:14:15: + at /pwd/in.nix:14:15: 13| # translated to LF. 14| foo = "multi | ^ diff --git a/tests/functional/lang/parse-okay-crlf.nix b/tests/functional2/lang/line_endings/in.nix similarity index 100% rename from tests/functional/lang/parse-okay-crlf.nix rename to tests/functional2/lang/line_endings/in.nix diff --git a/tests/functional2/lang/line_endings/test.toml b/tests/functional2/lang/line_endings/test.toml new file mode 100644 index 000000000..beff445a7 --- /dev/null +++ b/tests/functional2/lang/line_endings/test.toml @@ -0,0 +1,6 @@ +[depr] +runner = "parse-fail" + +[allow-depr] +runner = "parse-okay" +flags = ["--extra-deprecated-features", "cr-line-endings"] diff --git a/tests/functional/lang/eval-okay-nul.exp b/tests/functional2/lang/nul_bytes/eval-allow-depr.out.exp similarity index 100% rename from tests/functional/lang/eval-okay-nul.exp rename to tests/functional2/lang/nul_bytes/eval-allow-depr.out.exp diff --git a/tests/functional/lang/parse-fail-nul.err.exp b/tests/functional2/lang/nul_bytes/eval-depr.err.exp similarity index 87% rename from tests/functional/lang/parse-fail-nul.err.exp rename to tests/functional2/lang/nul_bytes/eval-depr.err.exp index b0f3eb3b88c726b82f498131967fda9e0e2309d8..3512163d098e192923fe620d1b86a0bf73ffc242 100644 GIT binary patch delta 12 TcmdnYw1R2EBc{x}iSJziA$$dI delta 23 ecmZ3%w3%tbBi_`q#2nrH?8HjlywaSBPh0?RZV8b>!3`INV6d##dpmLgwK0}c$TTz6znOcBC2^0m}fDd2QL5FbUd;BC>HEN6V zKUz!~rMTSF~hJ%+z{M;VfQ~QrL;kaUdi}9r+-9G`W!1q(