Add regression tests for #9917, #9918

Change-Id: Ib0591e1499c5dba5e5a83ee75a899c9d16986827
This commit is contained in:
jade 2024-03-09 23:59:50 -08:00
parent b85085157a
commit 9c3a1babe6
5 changed files with 55 additions and 0 deletions

View file

@ -0,0 +1,9 @@
let
a = builtins.trace "before inner break" (
builtins.break { msg = "hello"; }
);
b = builtins.trace "before outer break" (
builtins.break a
);
in
b

View file

@ -0,0 +1,14 @@
https://github.com/NixOS/nix/pull/9917 (Enter debugger more reliably in let expressions and function calls)
This test ensures that continues don't skip opportunities to enter the debugger.
trace: before outer break
info: breakpoint reached
nix-repl> :c
trace: before inner break
info: breakpoint reached
nix-repl> :c
nix-repl> msg
"hello"

View file

@ -0,0 +1,5 @@
let
r = [];
x = builtins.throw r;
in
x

View file

@ -0,0 +1,16 @@
error:
… while evaluating the error message passed to builtin.throw
error: cannot coerce a list to a string: [ ]
We expect to be able to see locals like r in the debugger:
nix-repl> r
[ ]
nix-repl> :env
Env level 0
static: x r
Env level 1
builtins true false null scopedImport import isNull break abort throw derivationStrict placeholder baseNameOf dirOf removeAttrs map toString fetchMercurial fetchTree fetchTarball fetchGit fromTOML derivation

View file

@ -94,4 +94,15 @@ TEST_F(ReplSessionTest, repl_basic)
readTest("basic_repl.test", [this](std::string input) { runReplTest(input); }); readTest("basic_repl.test", [this](std::string input) { runReplTest(input); });
} }
#define DEBUGGER_TEST(name) \
TEST_F(ReplSessionTest, name) \
{ \
readTest(#name ".test", [this](std::string input) { \
runReplTest(input, {"--debugger", "-f", goldenMaster(#name ".nix")}); \
}); \
}
DEBUGGER_TEST(regression_9918);
DEBUGGER_TEST(regression_9917);
}; };