Skip to content

Commit

Permalink
fix: valgrind script
Browse files Browse the repository at this point in the history
  • Loading branch information
araujo88 committed Feb 1, 2025
1 parent dee7bf1 commit a269661
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ jobs:

- name: Run Valgrind on all .brainrot tests
run: |
for f in test_cases/*.brainrot; do
echo "Running Valgrind on $f..."
valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
echo
done
chmod +x run_valgrind_tests.sh
./run_valgrind_tests.sh
working-directory: .
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FLEX := flex
PYTHON := python3

# Compiler and linker flags
CFLAGS := -Wall -Wextra -O2
CFLAGS := -Wall -Wextra -Wpedantic -O2
LDFLAGS := -lfl -lm

# Source files and directories
Expand Down Expand Up @@ -54,13 +54,7 @@ clean:
# Run Valgrind on all .brainrot tests
.PHONY: valgrind
valgrind:
@for f in test_cases/*.brainrot; do \
echo "Ayo, Valgrind is pulling up on $$f..."; \
valgrind --leak-check=full --error-exitcode=1 ./$(TARGET) $$f; \
if [ $$? -eq 0 ]; then echo "Valgrind passed for $$f, no memory leaks. Big W!"; \
else echo "Valgrind found a memory leak in $$f, taking an L. Better grind harder."; exit 1; fi; \
echo; \
done
@./run_valgrind_tests.sh
@echo "Valgrind check done. If anything was sus, it'll show up with a non-zero exit code. No cap."

# Install target
Expand Down
15 changes: 13 additions & 2 deletions run_valgrind_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@

for f in test_cases/*.brainrot; do
echo "Running Valgrind on $f..."
if [[ $(basename "$f") == slorp_int* ]]; then
echo "42" | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
base=$(basename "$f" .brainrot)
if [[ "$base" == slorp_int ]]; then
echo 42 | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
elif [[ "$base" == slorp_short ]]; then
echo 69 | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
elif [[ "$base" == slorp_float ]]; then
echo "3.14" | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
elif [[ "$base" == slorp_double ]]; then
echo "3.141592" | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
elif [[ "$base" == slorp_char ]]; then
echo "c" | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
elif [[ "$base" == slorp_string ]]; then
echo "skibidi bop bop yes yes" | valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
else
valgrind --leak-check=full --error-exitcode=1 ./brainrot "$f"
fi
Expand Down

0 comments on commit a269661

Please sign in to comment.