Skip to content

Commit

Permalink
Add regression tests for #9917, #9918
Browse files Browse the repository at this point in the history
  • Loading branch information
lf- committed Mar 6, 2024
1 parent 11b391a commit 3e0a5bb
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions tests/functional/repl_characterization/data/regression_9917.test
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
let
r = [];
x = builtins.throw r;
in
x
16 changes: 16 additions & 0 deletions tests/functional/repl_characterization/data/regression_9918.test
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions tests/functional/repl_characterization/repl_characterization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,15 @@ TEST_F(ReplSessionTest, repl_basic)
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);

};

0 comments on commit 3e0a5bb

Please sign in to comment.