python3Packages.pytestCheckHook: support enabledTestPaths
This commit is contained in:
@@ -204,6 +204,55 @@ in
|
||||
] ++ previousPythonAttrs.disabledTestPaths or [ ];
|
||||
})
|
||||
);
|
||||
enabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: {
|
||||
pname = "test-pytestCheckHook-enabledTestPaths-${previousPythonAttrs.pname}";
|
||||
enabledTestPaths = [
|
||||
"tests/test_basic.py"
|
||||
] ++ previousPythonAttrs.enabledTestPaths or [ ];
|
||||
});
|
||||
enabledTestPaths-nonexistent = testers.testBuildFailure (
|
||||
objprint.overridePythonAttrs (previousPythonAttrs: {
|
||||
pname = "test-pytestCheckHook-enabledTestPaths-nonexistent-${previousPythonAttrs.pname}";
|
||||
enabledTestPaths = [
|
||||
"tests/test_foo.py"
|
||||
] ++ previousPythonAttrs.enabledTestPaths or [ ];
|
||||
})
|
||||
);
|
||||
enabledTestPaths-dir = objprint.overridePythonAttrs (previousPythonAttrs: {
|
||||
pname = "test-pytestCheckHook-enabledTestPaths-dir-${previousPythonAttrs.pname}";
|
||||
enabledTestPaths = [
|
||||
"tests"
|
||||
] ++ previousPythonAttrs.enabledTestPaths or [ ];
|
||||
});
|
||||
enabledTestPaths-dir-disabledTestPaths = objprint.overridePythonAttrs (previousPythonAttrs: {
|
||||
pname = "test-pytestCheckHook-enabledTestPaths-dir-disabledTestPaths-${previousPythonAttrs.pname}";
|
||||
enabledTestPaths = [
|
||||
"tests"
|
||||
] ++ previousPythonAttrs.enabledTestPaths or [ ];
|
||||
disabledTestPaths = [
|
||||
"tests/test_basic.py"
|
||||
] ++ previousPythonAttrs.disabledTestPaths or [ ];
|
||||
});
|
||||
enabledTestPaths-glob = objprint.overridePythonAttrs (previousPythonAttrs: {
|
||||
pname = "test-pytestCheckHook-enabledTestPaths-glob-${previousPythonAttrs.pname}";
|
||||
enabledTestPaths = [
|
||||
"tests/test_obj*.py"
|
||||
] ++ previousPythonAttrs.enabledTestPaths or [ ];
|
||||
});
|
||||
enabledTestPaths-glob-nonexistent = testers.testBuildFailure (
|
||||
objprint.overridePythonAttrs (previousPythonAttrs: {
|
||||
pname = "test-pytestCheckHook-enabledTestPaths-glob-nonexistent-${previousPythonAttrs.pname}";
|
||||
enabledTestPaths = [
|
||||
"tests/test_foo*.py"
|
||||
] ++ previousPythonAttrs.enabledTestPaths or [ ];
|
||||
})
|
||||
);
|
||||
enabledTestPaths-item = objprint.overridePythonAttrs (previousPythonAttrs: {
|
||||
pname = "test-pytestCheckHook-enabledTestPaths-item-${previousPythonAttrs.pname}";
|
||||
enabledTestPaths = [
|
||||
"tests/test_basic.py::TestBasic"
|
||||
] ++ previousPythonAttrs.enabledTestPaths or [ ];
|
||||
});
|
||||
};
|
||||
};
|
||||
} ./pytest-check-hook.sh
|
||||
|
||||
@@ -10,7 +10,33 @@ function pytestCheckPhase() {
|
||||
# Compose arguments
|
||||
local -a flagsArray=(-m pytest)
|
||||
|
||||
local -a _pathsArray=()
|
||||
local -a _pathsArray
|
||||
local path
|
||||
|
||||
_pathsArray=()
|
||||
concatTo _pathsArray enabledTestPaths
|
||||
for path in "${_pathsArray[@]}"; do
|
||||
if [[ "$path" =~ "::" ]]; then
|
||||
flagsArray+=("$path")
|
||||
else
|
||||
# The `|| kill "$$"` trick propagates the errors from the process substitutiton subshell,
|
||||
# which is suggested by a StackOverflow answer: https://unix.stackexchange.com/a/217643
|
||||
readarray -t -O"${#flagsArray[@]}" flagsArray < <(@pythonCheckInterpreter@ - "$path" <<EOF || kill "$$")
|
||||
import glob
|
||||
import sys
|
||||
path_glob=sys.argv[1]
|
||||
if not len(path_glob):
|
||||
sys.exit('Got an empty enabled tests path glob. Aborting')
|
||||
path_expanded = glob.glob(path_glob)
|
||||
if not len(path_expanded):
|
||||
sys.exit('Enabled tests path glob "{}" does not match any paths. Aborting'.format(path_glob))
|
||||
for path in path_expanded:
|
||||
print(path)
|
||||
EOF
|
||||
fi
|
||||
done
|
||||
|
||||
_pathsArray=()
|
||||
concatTo _pathsArray disabledTestPaths
|
||||
for path in "${_pathsArray[@]}"; do
|
||||
if [[ "$path" =~ "::" ]]; then
|
||||
|
||||
@@ -108,6 +108,7 @@ let
|
||||
"format"
|
||||
"disabledTestPaths"
|
||||
"disabledTests"
|
||||
"enabledTestPaths"
|
||||
"pytestFlags"
|
||||
"pytestFlagsArray"
|
||||
"unittestFlags"
|
||||
@@ -446,6 +447,19 @@ let
|
||||
"unittestFlags"
|
||||
"unittestFlagsArray"
|
||||
] attrs
|
||||
//
|
||||
lib.mapAttrs
|
||||
(
|
||||
name: value:
|
||||
lib.throwIf (attrs.${name} == [ ])
|
||||
"${lib.getName finalAttrs}: ${name} must be unspecified, null or a non-empty list."
|
||||
attrs.${name}
|
||||
)
|
||||
(
|
||||
getOptionalAttrs [
|
||||
"enabledTestPaths"
|
||||
] attrs
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user