tests/functional2: migrate debugger.sh

Change-Id: I82c5b739db09530ff216c91608be2f70a2036e11
This commit is contained in:
Commentator2.0
2025-10-18 11:23:43 +00:00
committed by Rutile
parent e8d281eac6
commit 4fcfdc66fe
3 changed files with 29 additions and 14 deletions
-13
View File
@@ -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
-1
View File
@@ -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',
+29
View File
@@ -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)