88d8f6ac48
The original `builtins.getContext` test from1d757292d0
would have caught this. The problem is thatb30be6b450
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.
41 lines
1 KiB
Nix
41 lines
1 KiB
Nix
let
|
|
drv = derivation {
|
|
name = "fail";
|
|
builder = "/bin/false";
|
|
system = "x86_64-linux";
|
|
outputs = [ "out" "foo" ];
|
|
};
|
|
|
|
path = "${./eval-okay-context-introspection.nix}";
|
|
|
|
desired-context = {
|
|
"${builtins.unsafeDiscardStringContext path}" = {
|
|
path = true;
|
|
};
|
|
"${builtins.unsafeDiscardStringContext drv.drvPath}" = {
|
|
outputs = [ "foo" "out" ];
|
|
allOutputs = true;
|
|
};
|
|
};
|
|
|
|
combo-path = "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
|
|
legit-context = builtins.getContext combo-path;
|
|
|
|
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))
|
|
]
|