aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-03-09 23:59:50 -0800
committerJade Lovelace <lix@jade.fyi>2024-03-15 12:31:16 -0700
commit8a8715af89c0223e441772d38be6363b86452705 (patch)
tree8a69d8713ae6aeef41a2675d41660544b01a8833 /tests
parent18ed6c3bdf2c03c763c0d128083f507295bcf864 (diff)
Add regression tests for #9917, #9918
Change-Id: Ib0591e1499c5dba5e5a83ee75a899c9d16986827
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/repl_characterization/data/regression_9917.nix9
-rw-r--r--tests/functional/repl_characterization/data/regression_9917.test14
-rw-r--r--tests/functional/repl_characterization/data/regression_9918.nix5
-rw-r--r--tests/functional/repl_characterization/data/regression_9918.test16
-rw-r--r--tests/functional/repl_characterization/repl_characterization.cc11
5 files changed, 55 insertions, 0 deletions
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 993c30232..200eda1ee 100644
--- a/tests/functional/repl_characterization/repl_characterization.cc
+++ b/tests/functional/repl_characterization/repl_characterization.cc
@@ -97,4 +97,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);
+
};