summary refs log tree commit diff
path: root/pkgs/development/interpreters/python/hooks
diff options
context:
space:
mode:
authorWinter <winter@winter.cafe>2022-08-06 12:31:53 -0400
committerWinter <winter@winter.cafe>2022-08-13 14:09:43 -0400
commite8fbb38a51380fe6e56351b5750dddcccff79c4c (patch)
treedc44893b7aafd2ed43f7c5ad3f550091211fe355 /pkgs/development/interpreters/python/hooks
parenta5a853e4465f7e1d25e54fa8981bff20e99d380c (diff)
downloadnixpkgs-e8fbb38a51380fe6e56351b5750dddcccff79c4c.tar
nixpkgs-e8fbb38a51380fe6e56351b5750dddcccff79c4c.tar.gz
nixpkgs-e8fbb38a51380fe6e56351b5750dddcccff79c4c.tar.bz2
nixpkgs-e8fbb38a51380fe6e56351b5750dddcccff79c4c.tar.lz
nixpkgs-e8fbb38a51380fe6e56351b5750dddcccff79c4c.tar.xz
nixpkgs-e8fbb38a51380fe6e56351b5750dddcccff79c4c.tar.zst
nixpkgs-e8fbb38a51380fe6e56351b5750dddcccff79c4c.zip
pythonPackages.unittestCheckHook: init
Diffstat (limited to 'pkgs/development/interpreters/python/hooks')
-rw-r--r--pkgs/development/interpreters/python/hooks/default.nix8
-rw-r--r--pkgs/development/interpreters/python/hooks/unittest-check-hook.sh29
2 files changed, 37 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/python/hooks/default.nix b/pkgs/development/interpreters/python/hooks/default.nix
index 34c6a72662d..0f175c90920 100644
--- a/pkgs/development/interpreters/python/hooks/default.nix
+++ b/pkgs/development/interpreters/python/hooks/default.nix
@@ -164,6 +164,14 @@ in rec {
       };
     } ./setuptools-check-hook.sh) {};
 
+  unittestCheckHook = callPackage ({ }:
+    makeSetupHook {
+      name = "unittest-check-hook";
+      substitutions = {
+        inherit pythonCheckInterpreter;
+      };
+    } ./unittest-check-hook.sh) {};
+
   venvShellHook = disabledIf (!isPy3k) (callPackage ({ }:
     makeSetupHook {
       name = "venv-shell-hook";
diff --git a/pkgs/development/interpreters/python/hooks/unittest-check-hook.sh b/pkgs/development/interpreters/python/hooks/unittest-check-hook.sh
new file mode 100644
index 00000000000..3485fcc7945
--- /dev/null
+++ b/pkgs/development/interpreters/python/hooks/unittest-check-hook.sh
@@ -0,0 +1,29 @@
+# Setup hook for unittest.
+echo "Sourcing unittest-check-hook"
+
+unittestCheckPhase() {
+    echo "Executing unittestCheckPhase"
+    runHook preCheck
+
+    eval "@pythonCheckInterpreter@ -m unittest discover $unittestFlagsArray"
+
+    runHook postCheck
+    echo "Finished executing unittestCheckPhase"
+}
+
+if [ -z "${dontUseUnittestCheck-}" ] && [ -z "${installCheckPhase-}" ]; then
+    echo "Using unittestCheckPhase"
+    preDistPhases+=" unittestCheckPhase"
+
+    # It's almost always the case that setuptoolsCheckPhase should not be ran
+    # when the unittestCheckHook is being ran
+    if [ -z "${useSetuptoolsCheck-}" ]; then
+        dontUseSetuptoolsCheck=1
+
+        # Remove command if already injected into preDistPhases
+        if [[ "$preDistPhases" =~ "setuptoolsCheckPhase" ]]; then
+            echo "Removing setuptoolsCheckPhase"
+            preDistPhases=${preDistPhases/setuptoolsCheckPhase/}
+        fi
+    fi
+fi