Skip to content

Commit 2cea433

Browse files
committed
fix(CI): make valgrind ignore brainrot exit code
Signed-off-by: SIGMazer <mazinasd7@gmail.com>
1 parent c787af2 commit 2cea433

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

run_valgrind_tests.sh

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,30 @@
33
for f in test_cases/*.brainrot; do
44
echo "Running Valgrind on $f..."
55
base=$(basename "$f" .brainrot)
6-
if [[ "$base" == slorp_int ]]; then
7-
echo 42 | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
8-
elif [[ "$base" == slorp_short ]]; then
9-
echo 69 | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
10-
elif [[ "$base" == slorp_float ]]; then
11-
echo "3.14" | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
12-
elif [[ "$base" == slorp_double ]]; then
13-
echo "3.141592" | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
14-
elif [[ "$base" == slorp_char ]]; then
15-
echo "c" | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
16-
elif [[ "$base" == slorp_string ]]; then
17-
echo "skibidi bop bop yes yes" | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
6+
7+
case "$base" in
8+
slorp_int) input="42" ;;
9+
slorp_short) input="69" ;;
10+
slorp_float) input="3.14" ;;
11+
slorp_double) input="3.141592" ;;
12+
slorp_char) input="c" ;;
13+
slorp_string) input="skibidi bop bop yes yes" ;;
14+
*) input="" ;;
15+
esac
16+
17+
if [[ -n "$input" ]]; then
18+
echo "$input" | valgrind --leak-check=full --error-exitcode=100 ./brainrot "$f"
1819
else
19-
valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
20+
valgrind --leak-check=full --error-exitcode=100 ./brainrot "$f"
2021
fi
21-
if [[ $? -ne 0 ]]; then
22-
echo "Valgrind failed on $f"
22+
23+
valgrind_exit_code=$? # Capture only valgrind’s exit code
24+
25+
if [[ $valgrind_exit_code -eq 100 ]]; then
26+
echo "Valgrind detected memory issues in $f"
2327
exit 1
2428
fi
29+
2530
echo
2631
done
32+

0 commit comments

Comments
 (0)