From 6bef4bdc263fd75cf43f63ff03c8eb48c4b3ec2c Mon Sep 17 00:00:00 2001 From: Scarlett Date: Sun, 4 May 2025 16:23:35 -0400 Subject: [PATCH] make --- Makefile | 36 +++++++++---------------- test.sh | 24 +++++++++++++++-- tests/sprint4/expected/sp4_cg_sub.s.exp | 1 - 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 794b839..68a4858 100644 --- a/Makefile +++ b/Makefile @@ -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 # ----------- \ No newline at end of file diff --git a/test.sh b/test.sh index 3f3c266..ce2d31d 100755 --- a/test.sh +++ b/test.sh @@ -33,8 +33,26 @@ if [ $# -eq 0 ]; then fi help() { - echo -e "${GREEN}[HELP] ${YELLOW}Usage: ./test.sh [-exp] ${WHITE}" - echo -e "${GREEN}[HELP] ${YELLOW}To all tests in a folder: ./test/sh / [-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 [flags] ${WHITE} Run the test on a single file" + echo -e "${GREEN} ./test.sh [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: [ ] *)" + echo -e "${ORANGE} where 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 diff --git a/tests/sprint4/expected/sp4_cg_sub.s.exp b/tests/sprint4/expected/sp4_cg_sub.s.exp index 8bf3d80..743ef59 100644 --- a/tests/sprint4/expected/sp4_cg_sub.s.exp +++ b/tests/sprint4/expected/sp4_cg_sub.s.exp @@ -9,4 +9,3 @@ movl %eax, -20(%rbp) #subtraction end movl -20(%rbp), %eax #assign start movl %eax, -8(%rbp) #assign end -s \ No newline at end of file