Skip to content

Commit 88ec81a

Browse files
LarsEckartisidoreJayBazuzi
committed
. e build_and_test.sh: Sum only 'Tests run' lines immediately after 'Results:' for correct multi-module Maven totals
This ensures the total test count reflects only the summary lines for each module, fixing the previous logic which could overcount. Co-authored-by: Llewellyn <isidore@users.noreply.github.com> Co-authored-by: Jay <JayBazuzi@users.noreply.github.com>
1 parent b89cf28 commit 88ec81a

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

.windsurf/BashScriptStyle.process.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Bash Script Style Process
22

3+
STARTER_CHARACTER =💻
4+
35
- Use `#!/usr/bin/env bash` as shebang.
4-
- Always use `set -euxo pipefail` for safety and debugging.
6+
- Always use `set -euo pipefail` for safety and debugging.
57
- Keep scripts minimal: no unnecessary comments or echoes.
68
- Only do minimal input validation; print a usage message to stderr and exit if inputs are missing or invalid.
79
- Do not check for installed commands if failure will be obvious on use.

build_and_test.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,22 @@ set -euo pipefail
44
TMP_OUTPUT=$(mktemp)
55
if mvn -B verify --file pom.xml > "$TMP_OUTPUT" 2>&1; then
66
# Extract the number of tests run from Maven output
7-
TESTS_LINE=$(awk '/Results:/ {found=1; next} found' "$TMP_OUTPUT" | grep -Eo 'Tests run: [0-9]+' | head -n 1)
8-
TESTS_PASSED=$(echo "$TESTS_LINE" | grep -Eo '[0-9]+')
9-
echo "✅ Built: $TESTS_PASSED tests passed."
7+
TESTS_TOTAL=$(awk '
8+
/Results:/ {
9+
for(i=0;i<3;i++) {
10+
if(getline>0) {
11+
if($0 ~ /Tests run: [0-9]+/) {
12+
line = $0
13+
sub(/.*Tests run: /, "", line)
14+
sub(/[^0-9].*$/, "", line)
15+
sum += line
16+
break
17+
}
18+
}
19+
}
20+
}
21+
END {print sum}' "$TMP_OUTPUT")
22+
echo "✅ Built: $TESTS_TOTAL tests passed."
1023
EXIT_CODE=0
1124
else
1225
cat "$TMP_OUTPUT"

0 commit comments

Comments
 (0)