From 2e2f18813c2417cae4accd759b0a2e3bb0f3e476 Mon Sep 17 00:00:00 2001 From: natsukium Date: Mon, 15 Jul 2024 12:35:06 +0900 Subject: [PATCH] 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`. --- .../interpreters/python/mk-python-derivation.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/development/interpreters/python/mk-python-derivation.nix b/pkgs/development/interpreters/python/mk-python-derivation.nix index 0d6ab2224991..b85e76bb69ee 100644 --- a/pkgs/development/interpreters/python/mk-python-derivation.nix +++ b/pkgs/development/interpreters/python/mk-python-derivation.nix @@ -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}")