Modify the existing coverage collection method (#3573)

fix cov report
This commit is contained in:
YUNSHEN XIE
2025-08-25 10:35:35 +08:00
committed by GitHub
parent 7821534ff5
commit 46664985fc
4 changed files with 23 additions and 5 deletions

View File

@@ -1,7 +1,11 @@
#!/bin/bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
run_path="$DIR/../tests/"
export PYTEST_INI="$DIR/../tests/pytest.ini"
export PYTEST_INI="$DIR/../tests/cov_pytest.ini"
export COVERAGE_FILE=${COVERAGE_FILE:-$DIR/../coveragedata/.coverage}
export COVERAGE_RCFILE=${COVERAGE_RCFILE:-$DIR/../scripts/.coveragerc}
export COVERAGE_PROCESS_START=${COVERAGE_PROCESS_START:-$DIR/../scripts/.coveragerc}
cd "$run_path" || exit 1
failed_tests_file="failed_tests.log"
@@ -46,7 +50,7 @@ done
# 执行 pytest每个文件单独跑
##################################
# 收集 pytest 文件
TEST_FILES=$(python -m pytest --collect-only -q -c pytest.ini --disable-warnings | grep -Eo '^.*test_.*\.py' | sort | uniq)
TEST_FILES=$(python -m pytest --collect-only -q -c ${PYTEST_INI} --disable-warnings | grep -Eo '^.*test_.*\.py' | sort | uniq)
failed_pytest=0
@@ -54,7 +58,7 @@ success_pytest=0
for file in $TEST_FILES; do
echo "Running pytest file: $file"
python -m coverage run --parallel-mode -m pytest "$file" -vv -s
python -m pytest -c ${PYTEST_INI} --cov-config=${COVERAGE_RCFILE} "$file" -vv -s
status=$?
if [ "$status" -ne 0 ]; then
echo "$file" >> "$failed_tests_file"