This commit is contained in:
Scarlett
2025-05-04 16:23:35 -04:00
parent a61d0a57e8
commit 6bef4bdc26
3 changed files with 35 additions and 26 deletions

View File

@ -12,11 +12,6 @@ YACC := src/grammar.y
EXE := alpha
OBJS := tmp/runner.o tmp/symbol_table.o tmp/grammar.tab.o tmp/lex.yy.o tmp/intermediate_code.o tmp/codegen.o
TESTS-S1 := $(wildcard tests/sprint1/test/*.alpha)
TESTS-S2 := $(wildcard tests/sprint2/test/*.alpha)
TESTS-S3 := $(wildcard tests/sprint3/test/*.alpha)
TESTS-S4 := $(wildcard tests/sprint4/test/*.alpha)
# ----------
@ -71,35 +66,30 @@ tmp/runner.o: src/runner.c src/runner.h tmp/flex.h tmp/grammar.tab.h
# ----- Tests -----
test:
chmod +x ./check.sh
chmod +x ./test.sh
$(foreach test, $(TESTS-S1), (./$(EXE) -tok -debug $(test) || true);)
./test.sh sp2
./test.sh sp3
./test.sh sp4
./check.sh
./test.sh tests/sprint1/test/ -diff
./test.sh tests/sprint2/test/ -diff
./test.sh tests/sprint3/test/ -diff
./test.sh tests/sprint4/test/ -diff
./test.sh tests/given/test/ -diff
test-s1:
chmod +x ./check.sh
chmod +x ./test.sh
$(foreach test, $(TESTS-S1), (./$(EXE) -tok -debug $(test) || true);)
./check.sh sp1
./test.sh tests/sprint1/test/ -diff
test-s2:
chmod +x ./check.sh
chmod +x ./test.sh
./test.sh sp2
./check.sh sp2
./test.sh tests/sprint2/test/ -diff
test-s3:
chmod +x ./check.sh
chmod +x ./test.sh
./test.sh sp3
./check.sh sp3
./test.sh tests/sprint3/test/ -diff
test-s4:
chmod +x ./check.sh
chmod +x ./test.sh
./test.sh sp4
./check.sh sp4
./test.sh tests/sprint4/test/ -diff
test-given:
chmod +x ./test.sh
./test.sh tests/given/test/ -diff
# -----------

24
test.sh
View File

@ -33,8 +33,26 @@ if [ $# -eq 0 ]; then
fi
help() {
echo -e "${GREEN}[HELP] ${YELLOW}Usage: ./test.sh <file> [-exp] ${WHITE}"
echo -e "${GREEN}[HELP] ${YELLOW}To all tests in a folder: ./test/sh <dir>/ [-exp]${WHITE}"
echo -e "${WHITE}-----{ ${BLUE}Test.sh Help ${WHITE}}-----\n"
echo -e "${YELLOW} Arguments: ${WHITE}"
echo -e "${GREEN} -exp ${WHITE} Generate expected output files"
echo -e "${GREEN} -diff ${WHITE} Compare output files with expected output files"
echo -e "${GREEN} -help ${WHITE} Show this help message\n"
echo -e "${YELLOW} Usage: ${WHITE}"
echo -e "${GREEN} ./test.sh <file.alpha> [flags] ${WHITE} Run the test on a single file"
echo -e "${GREEN} ./test.sh <directory> [flags] ${WHITE} Run the test on all files in a directory\n"
echo -e "${YELLOW} Examples: ${WHITE}"
echo -e "${GREEN} ./test.sh test.alpha ${WHITE} Runs test flags in header on test.alpha"
echo -e "${GREEN} ./test.sh test/ ${WHITE} Runs test flags in header on all .alpha files in test/"
echo -e "${GREEN} ./test.sh test/ -exp ${WHITE} Runs test flags in header on all .alpha files in test/ and generates expected output files"
echo -e "${GREEN} ./test.sh test/ -diff ${WHITE} Runs test flags in header on all .alpha files in test/ and compares output files with expected output files"
echo -e "${GREEN} ./test.sh test/ -exp -diff ${WHITE} Runs test flags in header on all .alpha files in test/ and generates expected output files and compares output files with expected output files\n"
echo -e "${YELLOW} Notes: ${WHITE}"
echo -e "${ORANGE} To create a test file, on the first line of the .alpha file, add:"
echo -e "${LIGHTBLUE} (* TEST: [ <test_flags> ] *)"
echo -e "${ORANGE} where <test_flags> are the alpha flags to be used. Ex:"
echo -e "${LIGHTBLUE} (* TEST: [ -debug -asc -tc ] *)\n"
echo -e "${WHITE}-----------------------------------------\n"
exit 1
}
@ -136,4 +154,6 @@ if [ -f "$1" ]; then
echo -e "${RED}[ERROR] ${YELLOW}File $1 is not a .alpha file!${WHITE}"
help
fi
else
help
fi

View File

@ -9,4 +9,3 @@
movl %eax, -20(%rbp) #subtraction end
movl -20(%rbp), %eax #assign start
movl %eax, -8(%rbp) #assign end
s