Unverified Commit 6a7fbeea authored by Martin Weinelt's avatar Martin Weinelt Committed by GitHub
Browse files

pytestCheckHook: fix disabledTestPaths glob matching assertion (#386491)

parents ce818565 9346e6aa
Loading
Loading
Loading
Loading
+48 −1
Original line number Diff line number Diff line
@@ -146,13 +146,60 @@ in
      };

  pytestCheckHook = callPackage (
    { makePythonHook, pytest }:
    {
      makePythonHook,
      pytest,
      # For package tests
      testers,
      objprint,
    }:
    makePythonHook {
      name = "pytest-check-hook";
      propagatedBuildInputs = [ pytest ];
      substitutions = {
        inherit pythonCheckInterpreter;
      };
      passthru = {
        tests = {
          basic = objprint.overridePythonAttrs (previousPythonAttrs: {
            pname = "test-pytestCheckHook-basic-${previousPythonAttrs.pname}";
          });
          disabledTests = objprint.overridePythonAttrs (previousPythonAttrs: {
            pname = "test-pytestCheckHook-disabledTests-${previousPythonAttrs.pname}";
            disabledTests = [
              "test_print"
            ] ++ previousPythonAttrs.disabledTests or [ ];
          });
          disabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: {
            pname = "test-pytestCheckHook-disabledTestPaths-${previousPythonAttrs.pname}";
            disabledTestPaths = [
              "tests/test_basic.py"
            ] ++ previousPythonAttrs.disabledTestPaths or [ ];
          });
          disabledTestPaths-nonexistent = testers.testBuildFailure (
            objprint.overridePythonAttrs (previousPythonAttrs: {
              pname = "test-pytestCheckHook-disabledTestPaths-nonexistent-${previousPythonAttrs.pname}";
              disabledTestPaths = [
                "tests/test_foo.py"
              ] ++ previousPythonAttrs.disabledTestPaths or [ ];
            })
          );
          disabledTestPaths-glob = objprint.overridePythonAttrs (previousPythonAttrs: {
            pname = "test-pytestCheckHook-disabledTestPaths-glob-${previousPythonAttrs.pname}";
            disabledTestPaths = [
              "tests/test_obj*.py"
            ] ++ previousPythonAttrs.disabledTestPaths or [ ];
          });
          disabledTestPaths-glob-nonexistent = testers.testBuildFailure (
            objprint.overridePythonAttrs (previousPythonAttrs: {
              pname = "test-pytestCheckHook-disabledTestPaths-glob-nonexistent-${previousPythonAttrs.pname}";
              disabledTestPaths = [
                "tests/test_foo*.py"
              ] ++ previousPythonAttrs.disabledTestPaths or [ ];
            })
          );
        };
      };
    } ./pytest-check-hook.sh
  ) { };

+1 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ function pytestCheckPhase() {
    concatTo _pathsArray disabledTestPaths
    for path in "${_pathsArray[@]}"; do
        # Check if every path glob matches at least one path
        @pythonCheckInterpreter@ <(cat <<EOF
        @pythonCheckInterpreter@ - "$path" <<EOF
import glob
import sys
path_glob=sys.argv[1]
@@ -27,7 +27,6 @@ if not len(path_glob):
if next(glob.iglob(path_glob), None) is None:
    sys.exit('Disabled tests path glob "{}" does not match any paths. Aborting'.format(path_glob))
EOF
        ) "$path"
        flagsArray+=("--ignore-glob=$path")
    done