Skip to content

Commit cc4e525

Browse files
KenJones-Modularmodularbot
authored andcommitted
[puzzles] Fail the sanitizers task when any tool reports errors
The puzzles' combined sanitizer task now exits with an error when any sanitizer reports a problem, instead of always reporting success. MODULAR_ORIG_COMMIT_REV_ID: e56de6553dde8732fb9cac79ffedcd815351465f
1 parent 6f586ca commit cc4e525

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎solutions/sanitizer.sh‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ esac
7777
# Handle "all" tool option - run all sanitizers on all puzzles or specific puzzle
7878
if [ "$TOOL" = "all" ]; then
7979
TOOLS=("memcheck" "racecheck" "synccheck" "initcheck")
80+
# Each tool runs in a child invocation, so its exit status is the only
81+
# signal that it found errors. Run every tool, then fail if any did.
82+
FAILED_TOOLS=()
8083

8184
if [ -z "$SPECIFIC_PUZZLE" ]; then
8285
# Run all sanitizers on all puzzles
@@ -87,12 +90,16 @@ if [ "$TOOL" = "all" ]; then
8790
echo ""
8891
echo "Running $CURRENT_TOOL on all puzzles..."
8992
echo "-----------------------------------"
90-
bash "$0" "$CURRENT_TOOL"
93+
bash "$0" "$CURRENT_TOOL" || FAILED_TOOLS+=("$CURRENT_TOOL")
9194
echo ""
9295
done
9396

9497
echo "======================================================================="
9598
echo "All sanitizer tools completed for all puzzles"
99+
if [ ${#FAILED_TOOLS[@]} -gt 0 ]; then
100+
echo "Tools that reported errors: ${FAILED_TOOLS[*]}"
101+
exit 1
102+
fi
96103
exit 0
97104
fi
98105

@@ -114,15 +121,21 @@ if [ "$TOOL" = "all" ]; then
114121
echo "-----------------------------------"
115122
# Recursively call this script with individual tool and flag
116123
if [ -n "$SPECIFIC_FLAG" ]; then
117-
bash "$0" "$CURRENT_TOOL" "$SPECIFIC_PUZZLE" "$SPECIFIC_FLAG"
124+
bash "$0" "$CURRENT_TOOL" "$SPECIFIC_PUZZLE" "$SPECIFIC_FLAG" \
125+
|| FAILED_TOOLS+=("$CURRENT_TOOL")
118126
else
119-
bash "$0" "$CURRENT_TOOL" "$SPECIFIC_PUZZLE"
127+
bash "$0" "$CURRENT_TOOL" "$SPECIFIC_PUZZLE" \
128+
|| FAILED_TOOLS+=("$CURRENT_TOOL")
120129
fi
121130
echo ""
122131
done
123132

124133
echo "======================================================================="
125134
echo "All sanitizer tools completed for $SPECIFIC_PUZZLE"
135+
if [ ${#FAILED_TOOLS[@]} -gt 0 ]; then
136+
echo "Tools that reported errors: ${FAILED_TOOLS[*]}"
137+
exit 1
138+
fi
126139
exit 0
127140
fi
128141

0 commit comments

Comments
 (0)