From 3e0a5bb1ab53170da75e6403316508ed8b2258bc Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Tue, 5 Mar 2024 16:33:30 -0800 Subject: [PATCH] Add regression tests for #9917, #9918 --- .../data/regression_9917.nix | 9 +++++++++ .../data/regression_9917.test | 14 ++++++++++++++ .../data/regression_9918.nix | 5 +++++ .../data/regression_9918.test | 16 ++++++++++++++++ .../repl_characterization.cc | 11 +++++++++++ 5 files changed, 55 insertions(+) create mode 100644 tests/functional/repl_characterization/data/regression_9917.nix create mode 100644 tests/functional/repl_characterization/data/regression_9917.test create mode 100644 tests/functional/repl_characterization/data/regression_9918.nix create mode 100644 tests/functional/repl_characterization/data/regression_9918.test 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 000000000000..ab49ce3a2288 --- /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 000000000000..a37ea5805c83 --- /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 000000000000..3860ce70e0e7 --- /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 000000000000..4a1931122e26 --- /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 28e4706a304f..9ee56bb37601 100644 --- a/tests/functional/repl_characterization/repl_characterization.cc +++ b/tests/functional/repl_characterization/repl_characterization.cc @@ -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); + };