mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-09-30 03:39:59 +00:00
pytestCheckHook: fix disabledTestPaths glob matching assertion (#386491)
This commit is contained in:
@@ -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
|
||||
) { };
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user