diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-21 23:50:09 -0500 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-21 23:50:09 -0500 |
commit | 88d8f6ac4817e44fba0a4f086ea0b8c06234cdd7 (patch) | |
tree | c957613cf5a423fdb52bd77cbef06b43c849afaa | |
parent | 04de0dd0b4059c75115c780dae8ddc49a847b0e5 (diff) |
Expand tests to reproduce #7655
The original `builtins.getContext` test from
1d757292d0cb78beec32fcdfe15c2944a4bc4a95 would have caught this. The
problem is that b30be6b450f872f8be6dc8afa28f4b030fa8d1d1 adding
`builtins.appendContext` modified that test to make it test too much at
once, rather than adding a separate test.
We now have isolated tests for both functions, and also a property test
showing everything put together (in the form of an eta rule for strings
with context). This is better coverage and properly reproduces the bug.
-rw-r--r-- | tests/lang/eval-okay-context-introspection.exp | 2 | ||||
-rw-r--r-- | tests/lang/eval-okay-context-introspection.nix | 23 |
2 files changed, 21 insertions, 4 deletions
diff --git a/tests/lang/eval-okay-context-introspection.exp b/tests/lang/eval-okay-context-introspection.exp index 27ba77dda..03b400cc8 100644 --- a/tests/lang/eval-okay-context-introspection.exp +++ b/tests/lang/eval-okay-context-introspection.exp @@ -1 +1 @@ -true +[ true true true true true true ] diff --git a/tests/lang/eval-okay-context-introspection.nix b/tests/lang/eval-okay-context-introspection.nix index 43178bd2e..50a78d946 100644 --- a/tests/lang/eval-okay-context-introspection.nix +++ b/tests/lang/eval-okay-context-introspection.nix @@ -18,7 +18,24 @@ let }; }; - legit-context = builtins.getContext "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}"; + combo-path = "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}"; + legit-context = builtins.getContext combo-path; - constructed-context = builtins.getContext (builtins.appendContext "" desired-context); -in legit-context == constructed-context + reconstructed-path = builtins.appendContext + (builtins.unsafeDiscardStringContext combo-path) + desired-context; + + # Eta rule for strings with context. + etaRule = str: + str == builtins.appendContext + (builtins.unsafeDiscardStringContext str) + (builtins.getContext str); + +in [ + (legit-context == desired-context) + (reconstructed-path == combo-path) + (etaRule "foo") + (etaRule drv.drvPath) + (etaRule drv.foo.outPath) + (etaRule (builtins.unsafeDiscardOutputDependency drv.drvPath)) +] |