mk-python-derivation: don't expose check args when doCheck = false

This change prevents rebuilds if we change check flags when
doCheck = false. It's useful, for example, when tests are separated in
`passthru.tests`.
This commit is contained in:
natsukium
2024-07-27 11:26:55 +09:00
parent 75ad9293a9
commit 2e2f18813c
@@ -62,7 +62,7 @@ let
cleanAttrs = lib.flip removeAttrs [
"disabled" "checkPhase" "checkInputs" "nativeCheckInputs" "doCheck" "doInstallCheck" "dontWrapPythonPrograms" "catchConflicts" "pyproject" "format"
"disabledTestPaths" "outputs" "stdenv"
"disabledTestPaths" "disabledTests" "pytestFlagsArray" "unittestFlagsArray" "outputs" "stdenv"
"dependencies" "optional-dependencies" "build-system"
];
@@ -342,9 +342,19 @@ let
# If given use the specified checkPhase, otherwise use the setup hook.
# Longer-term we should get rid of `checkPhase` and use `installCheckPhase`.
installCheckPhase = attrs.checkPhase;
} // optionalAttrs (disabledTestPaths != []) {
} // optionalAttrs (attrs.doCheck or true) (
optionalAttrs (disabledTestPaths != []) {
disabledTestPaths = escapeShellArgs disabledTestPaths;
}));
} // optionalAttrs (attrs ? disabledTests) {
# `escapeShellArgs` should be used as well as `disabledTestPaths`,
# but some packages rely on existing raw strings.
disabledTests = attrs.disabledTests;
} // optionalAttrs (attrs ? pytestFlagsArray) {
pytestFlagsArray = attrs.pytestFlagsArray;
} // optionalAttrs (attrs ? unittestFlagsArray) {
unittestFlagsArray = attrs.unittestFlagsArray;
}
)));
in extendDerivation
(disabled -> throw "${name} not supported for interpreter ${python.executable}")