diff --git a/pkgs/development/python-modules/pytest-xdist/default.nix b/pkgs/development/python-modules/pytest-xdist/default.nix index fa1b0f63fabcd..b17b6f2f763a6 100644 --- a/pkgs/development/python-modules/pytest-xdist/default.nix +++ b/pkgs/development/python-modules/pytest-xdist/default.nix @@ -9,6 +9,7 @@ , pytest , pytest-forked , psutil +, pexpect }: buildPythonPackage rec { @@ -25,9 +26,15 @@ buildPythonPackage rec { buildInputs = [ pytest ]; - checkInputs = [ pytestCheckHook filelock ]; + checkInputs = [ pytestCheckHook filelock pexpect ]; propagatedBuildInputs = [ execnet pytest-forked psutil ]; + pytestFlagsArray = [ + # pytest can already use xdist at this point + "--numprocesses=$NIX_BUILD_CORES" + "--forked" + ]; + # access file system disabledTests = [ "test_distribution_rsyncdirs_example" @@ -40,6 +47,8 @@ buildPythonPackage rec { "test_internal_errors_propagate_to_controller" ]; + setupHook = ./setup-hook.sh; + meta = with lib; { description = "Pytest xdist plugin for distributed testing and loop-on-failing modes"; homepage = "https://github.com/pytest-dev/pytest-xdist"; diff --git a/pkgs/development/python-modules/pytest-xdist/setup-hook.sh b/pkgs/development/python-modules/pytest-xdist/setup-hook.sh new file mode 100644 index 0000000000000..8bba79ca3360e --- /dev/null +++ b/pkgs/development/python-modules/pytest-xdist/setup-hook.sh @@ -0,0 +1,7 @@ +pytestXdistHook() { + pytestFlagsArray+=("--numprocesses=$NIX_BUILD_CORES" "--forked" ) +} + +if [ -z "${dontUsePytestXdist-}" ] && [ -z "${dontUsePytestCheck-}" ]; then + addEnvHooks "$hostOffset" pytestXdistHook +fi