diff --git a/tests/functional/repl_characterization/data/regression_9917.nix b/tests/functional/repl_characterization/data/regression_9917.nix new file mode 100644 index 000000000..ab49ce3a2 --- /dev/null +++ b/tests/functional/repl_characterization/data/regression_9917.nix @@ -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 diff --git a/tests/functional/repl_characterization/data/regression_9917.test b/tests/functional/repl_characterization/data/regression_9917.test new file mode 100644 index 000000000..a37ea5805 --- /dev/null +++ b/tests/functional/repl_characterization/data/regression_9917.test @@ -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" diff --git a/tests/functional/repl_characterization/data/regression_9918.nix b/tests/functional/repl_characterization/data/regression_9918.nix new file mode 100644 index 000000000..3860ce70e --- /dev/null +++ b/tests/functional/repl_characterization/data/regression_9918.nix @@ -0,0 +1,5 @@ +let + r = []; + x = builtins.throw r; +in + x diff --git a/tests/functional/repl_characterization/data/regression_9918.test b/tests/functional/repl_characterization/data/regression_9918.test new file mode 100644 index 000000000..4a1931122 --- /dev/null +++ b/tests/functional/repl_characterization/data/regression_9918.test @@ -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 diff --git a/tests/functional/repl_characterization/repl_characterization.cc b/tests/functional/repl_characterization/repl_characterization.cc index 395018299..a8d6c6d83 100644 --- a/tests/functional/repl_characterization/repl_characterization.cc +++ b/tests/functional/repl_characterization/repl_characterization.cc @@ -94,4 +94,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); + };