Skip to content

Commit 30789df

Browse files
committed
Address no-result PR review feedback
1 parent 49dd90d commit 30789df

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

scripts/test_utils.sh

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ collect_tests() {
174174
# Return the expected JUnit XML path for a test file
175175
junit_file_for_test() {
176176
local test_file=$1
177-
echo "${JUNIT_DIR}/${test_file//\//_}.xml"
177+
local flattened_test_file=${test_file//\//_}
178+
local test_hash
179+
test_hash=$(printf '%s' "$test_file" | cksum | awk '{print $1}')
180+
echo "${JUNIT_DIR}/${flattened_test_file}.${test_hash}.xml"
178181
}
179182

180183
# Record a failed test file in the execution summary
@@ -264,8 +267,9 @@ dry_run_full_file() {
264267
local test_file=$1
265268

266269
TOTAL_TESTS=$((TOTAL_TESTS + 1))
267-
JUNIT_FILENAME="${test_file//\//_}.xml"
268-
JUNIT_FLAG="--junitxml=${JUNIT_DIR}/${JUNIT_FILENAME}"
270+
local junit_file
271+
junit_file=$(junit_file_for_test "$test_file")
272+
JUNIT_FLAG="--junitxml=${junit_file}"
269273
# shellcheck disable=SC2086 # PYTEST_COMMAND_PREFIX needs word splitting
270274
echo "$TOTAL_TESTS. ${PYTEST_COMMAND_PREFIX} pytest $PYTEST_FLAGS ${JUNIT_FLAG} \"${test_file}\""
271275
}
@@ -684,6 +688,14 @@ run_tests_parallel() {
684688

685689
TOTAL_TESTS=$((TOTAL_TESTS + 1))
686690

691+
if [ "$mode" = "sanity" ] && [[ "$result" == PASSED:* || "$result" == FAILED:* ]]; then
692+
local total_in_file sampled_in_file
693+
# shellcheck disable=SC2034 # status is part of the read but unused
694+
IFS=':' read -r _ total_in_file sampled_in_file <<< "$result"
695+
TOTAL_TEST_CASES=$((TOTAL_TEST_CASES + total_in_file))
696+
SAMPLED_TEST_CASES=$((SAMPLED_TEST_CASES + sampled_in_file))
697+
fi
698+
687699
if [ ! -f "$junit_file" ]; then
688700
echo "⚠️ NO RESULT: $test_file (missing JUnit XML: $junit_file)"
689701
record_no_result_test "$test_file"
@@ -692,22 +704,8 @@ run_tests_parallel() {
692704

693705
if [[ "$result" == PASSED* ]]; then
694706
PASSED_TESTS=$((PASSED_TESTS + 1))
695-
if [ "$mode" = "sanity" ]; then
696-
local total_in_file sampled_in_file
697-
# shellcheck disable=SC2034 # status is part of the read but unused
698-
IFS=':' read -r _ total_in_file sampled_in_file <<< "$result"
699-
TOTAL_TEST_CASES=$((TOTAL_TEST_CASES + total_in_file))
700-
SAMPLED_TEST_CASES=$((SAMPLED_TEST_CASES + sampled_in_file))
701-
fi
702707
elif [[ "$result" == FAILED* ]]; then
703708
record_failed_test "$test_file"
704-
if [ "$mode" = "sanity" ]; then
705-
local total_in_file sampled_in_file
706-
# shellcheck disable=SC2034 # status is part of the read but unused
707-
IFS=':' read -r _ total_in_file sampled_in_file <<< "$result"
708-
TOTAL_TEST_CASES=$((TOTAL_TEST_CASES + total_in_file))
709-
SAMPLED_TEST_CASES=$((SAMPLED_TEST_CASES + sampled_in_file))
710-
fi
711709
fi
712710
else
713711
TOTAL_TESTS=$((TOTAL_TESTS + 1))

0 commit comments

Comments
 (0)