From 4fcfdc66feff5650fff046d3319b39d6537bcc86 Mon Sep 17 00:00:00 2001 From: "Commentator2.0" Date: Tue, 14 Oct 2025 19:32:51 +0200 Subject: [PATCH] tests/functional2: migrate debugger.sh Change-Id: I82c5b739db09530ff216c91608be2f70a2036e11 --- tests/functional/debugger.sh | 13 ----------- tests/functional/meson.build | 1 - tests/functional2/eval/test_debugger.py | 29 +++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 14 deletions(-) delete mode 100644 tests/functional/debugger.sh create mode 100644 tests/functional2/eval/test_debugger.py diff --git a/tests/functional/debugger.sh b/tests/functional/debugger.sh deleted file mode 100644 index 63d88cbf3..000000000 --- a/tests/functional/debugger.sh +++ /dev/null @@ -1,13 +0,0 @@ -source common.sh - -clearStore - -# regression #9932 -echo ":env" | expect 1 nix eval --debugger --expr '(_: throw "oh snap") 42' -echo ":env" | expect 1 nix eval --debugger --expr ' - let x.a = 1; in - with x; - (_: builtins.seq x.a (throw "oh snap")) x.a -' >debugger-test-out -grep -P 'with: .*a' debugger-test-out -grep -P 'static: .*x' debugger-test-out diff --git a/tests/functional/meson.build b/tests/functional/meson.build index 4c0ff2513..c514bd9e5 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -158,7 +158,6 @@ functional_tests_scripts = [ 'toString-path.sh', 'read-only-store.sh', 'nested-sandboxing.sh', - 'debugger.sh', 'test-libstoreconsumer.sh', 'extra-sandbox-profile.sh', 'substitute-truncated-nar.sh', diff --git a/tests/functional2/eval/test_debugger.py b/tests/functional2/eval/test_debugger.py new file mode 100644 index 000000000..515fbb9dd --- /dev/null +++ b/tests/functional2/eval/test_debugger.py @@ -0,0 +1,29 @@ +import re +from textwrap import dedent + +from functional2.testlib.fixtures.nix import Nix + + +def test_regression_9932(nix: Nix): + cmd = nix.nix(["eval", "--debugger", "--expr", '(_: throw "oh snap") 42'], flake=True) + cmd.with_stdin(b":env") + res = cmd.run().expect(1) + assert "error: oh snap" in res.stderr_plain + + +def test_debugger_output(nix: Nix): + expr = dedent(""" + let x.a = 1; in + with x; + (_: builtins.seq x.a (throw "oh snap")) x.a + """) + + res = ( + nix.nix(["eval", "--debugger", "--expr", expr], flake=True) + .with_stdin(b":env\n") + .run() + .expect(1) + ) + assert "error: oh snap" in res.stderr_plain + assert re.findall(r"with: .*a", res.stdout_plain) + assert re.findall(r"static: .*x", res.stdout_plain)