Skip to content

Commit ef3236a

Browse files
fix: correct XML parsing for Kotlin test results
- Use correct module directory names (core, client, tools) - Parse <testsuite> elements from XML files correctly - Use find + grep + awk for reliable test count aggregation - Remove debug output for clean results - Tested locally to confirm all 209 tests are counted 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent be2e19c commit ef3236a

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

.github/workflows/test.yml

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -118,46 +118,39 @@ jobs:
118118
working-directory: sdks/community/kotlin/library
119119
run: |
120120
echo "## Kotlin SDK Test Results Summary"
121+
echo ""
122+
121123
total_tests=0
122124
total_failures=0
123125
total_errors=0
124-
total_skipped=0
125126
126-
for module in kotlin-core kotlin-client kotlin-tools; do
127+
for module in core client tools; do
127128
xml_dir="$module/build/test-results/jvmTest"
129+
128130
if [ -d "$xml_dir" ]; then
129-
module_tests=0
130-
module_failures=0
131-
module_errors=0
132-
module_skipped=0
133-
134-
# Parse XML test results
135-
for xml_file in "$xml_dir"/*.xml; do
136-
if [ -f "$xml_file" ]; then
137-
tests=$(grep -o 'tests="[0-9]*"' "$xml_file" | sed 's/tests="\([0-9]*\)"/\1/')
138-
failures=$(grep -o 'failures="[0-9]*"' "$xml_file" | sed 's/failures="\([0-9]*\)"/\1/')
139-
errors=$(grep -o 'errors="[0-9]*"' "$xml_file" | sed 's/errors="\([0-9]*\)"/\1/')
140-
skipped=$(grep -o 'skipped="[0-9]*"' "$xml_file" | sed 's/skipped="\([0-9]*\)"/\1/')
141-
142-
module_tests=$((module_tests + ${tests:-0}))
143-
module_failures=$((module_failures + ${failures:-0}))
144-
module_errors=$((module_errors + ${errors:-0}))
145-
module_skipped=$((module_skipped + ${skipped:-0}))
146-
fi
147-
done
148-
149-
if [ $module_tests -gt 0 ]; then
150-
echo "✅ $module: $module_tests tests, $module_failures failures, $module_errors errors"
131+
# Sum up test counts from all XML files in the directory
132+
module_tests=$(find "$xml_dir" -name "*.xml" -exec grep -h '<testsuite' {} \; | grep -o 'tests="[0-9]*"' | sed 's/tests="\([0-9]*\)"/\1/' | awk '{sum += $1} END {print sum}')
133+
module_failures=$(find "$xml_dir" -name "*.xml" -exec grep -h '<testsuite' {} \; | grep -o 'failures="[0-9]*"' | sed 's/failures="\([0-9]*\)"/\1/' | awk '{sum += $1} END {print sum}')
134+
module_errors=$(find "$xml_dir" -name "*.xml" -exec grep -h '<testsuite' {} \; | grep -o 'errors="[0-9]*"' | sed 's/errors="\([0-9]*\)"/\1/' | awk '{sum += $1} END {print sum}')
135+
136+
# Default to 0 if empty
137+
module_tests=${module_tests:-0}
138+
module_failures=${module_failures:-0}
139+
module_errors=${module_errors:-0}
140+
141+
if [ "$module_tests" -gt 0 ]; then
142+
echo "✅ kotlin-$module: $module_tests tests, $module_failures failures, $module_errors errors"
151143
total_tests=$((total_tests + module_tests))
152144
total_failures=$((total_failures + module_failures))
153145
total_errors=$((total_errors + module_errors))
154-
total_skipped=$((total_skipped + module_skipped))
155146
fi
156147
fi
157148
done
158149
150+
echo ""
159151
echo "---"
160-
echo "## Overall Results: $total_tests tests, $total_failures failures, $total_errors errors"
152+
echo "### Overall Results: $total_tests tests, $total_failures failures, $total_errors errors"
153+
161154
if [ $total_failures -gt 0 ] || [ $total_errors -gt 0 ]; then
162155
echo "❌ Some tests failed"
163156
exit 1

0 commit comments

Comments
 (0)