tests.buildenv: test passthru merging

buildEnv merges passthru from three sources:
  `{ inherit paths; } // derivationArgs.passthru // passthru`

Verify that:
- Auto-injected paths are present in passthru
- derivationArgs.passthru attributes are preserved
- Direct passthru attributes are preserved
- Direct passthru takes precedence over derivationArgs.passthru
This commit is contained in:
Philip Taron
2026-03-19 13:17:21 -07:00
parent fc93a90563
commit dbf1fa96d8
+47 -1
View File
@@ -118,7 +118,53 @@ let
};
};
tests = tests-name // tests-passthru-paths // tests-finalAttrs // tests-overrideAttrs;
tests-passthru-merging =
let
env = buildEnv {
name = "test-env";
paths = [ pkgs.hello ];
derivationArgs.passthru.fromDerivationArgs = "a";
passthru.fromPassthru = "b";
};
in
{
testPassthruMergingAutoPathsPresent = {
expr = env ? paths;
expected = true;
};
testPassthruMergingDerivationArgs = {
expr = env.fromDerivationArgs;
expected = "a";
};
testPassthruMergingDirectPassthru = {
expr = env.fromPassthru;
expected = "b";
};
# Direct passthru takes precedence over derivationArgs.passthru
testPassthruMergingPrecedence = {
expr =
let
env' = buildEnv {
name = "test-env";
paths = [ ];
derivationArgs.passthru.key = "from-derivationArgs";
passthru.key = "from-passthru";
};
in
env'.key;
expected = "from-passthru";
};
};
tests =
tests-name
// tests-passthru-paths
// tests-finalAttrs
// tests-overrideAttrs
// tests-passthru-merging;
in
stdenvNoCC.mkDerivation (finalAttrs: {