enable python unit test

This commit is contained in:
SoftFever
2026-09-09 00:10:02 +08:00
parent 58bf267fdd
commit 88586eea44
4 changed files with 41 additions and 10 deletions
+18
View File
@@ -17,6 +17,24 @@ cd "${ROOT_DIR}" || exit 1
TEST_DIR="${1:-build/tests}"
BUILD_CONFIG="${2:-}"
# The slic3rutils plugin-host tests build numpy arrays through the CPython copied next
# to the test binary (see tests/slic3rutils/CMakeLists.txt); that runtime ships pip but
# no numpy, so those tests SKIP without it. Install it into that interpreter's own
# site-packages -- no PYTHONPATH needed, and re-checked every run because a rebuild of
# the test target wipes and re-copies the runtime. Needs network on the first run only;
# a failure here is not fatal, the tests just keep skipping.
find_args=("${TEST_DIR}" \( -path '*/python/bin/python3' -o -path '*/python/python.exe' \))
# Multi-config trees hold one copy per configuration; only bootstrap the one being run.
[ -n "${BUILD_CONFIG}" ] && find_args+=(-path "*/${BUILD_CONFIG}/*")
python_exe="$(find "${find_args[@]}" -print -quit 2>/dev/null)"
if [ -z "${python_exe}" ]; then
echo "No bundled Python under ${TEST_DIR}; numpy-backed binding tests will skip."
elif ! "${python_exe}" -c "import numpy" >/dev/null 2>&1; then
echo "Installing numpy into the embedded test interpreter (${python_exe})..."
"${python_exe}" -m pip install --quiet --disable-pip-version-check --retries 1 "numpy<3" \
|| echo "numpy install failed; numpy-backed binding tests will skip."
fi
# Run the whole suite, excluding tests tagged [NotWorking].
# --no-tests=error fails the job if the filter matches nothing (instead of passing green).
args=(--test-dir "${TEST_DIR}" -LE "NotWorking" --no-tests=error --output-junit "$(pwd)/ctest_results.xml" --output-on-failure -j)