diff --git a/makefile b/makefile index 28eb98f..ca2de49 100644 --- a/makefile +++ b/makefile @@ -25,7 +25,7 @@ FLAGS += -Wdisabled-optimization FLAGS += -fanalyzer # These flags are because of the compiler otherwise giving too much warning FLAGS += -Wno-sign-conversion -#FLAGS += -Wformat-truncation=0 +FLAGS += -Wformat-truncation=0 # Compile flag for defining GITHASH to put at the end of the version string GITFLAG = -D'GITHASH=$(shell git rev-parse --short=1 HEAD)' @@ -37,6 +37,7 @@ OUTDIR = out # The UI to compile for by default using make run #UI_TARGET = vt100 UI_TARGET = ncurses +UI_TESTING = stub # The URL of the plaintext version of the lisence, for the --license option LICENSEURL = https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt @@ -44,6 +45,10 @@ LICENSEURL = https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt # C compiler CC = cc +# Test options +TEST_COLUMNS = 1000 +TEST_ROWS = 30 + .NOTINTERMEDIATE: # Messages to print during different steps in making @@ -65,6 +70,22 @@ run: $(OUTDIR)/connect4_$(UI_TARGET).elf run_%: $(OUTDIR)/connect4_%.elf ./$< +# Show result of test +test: test.diff + +# Diff between the tests +test.diff: test.log test.log.slow + diff -y $^ > $@ || tail $@ + diff -q $^ + +# Log of testing fast logic +test.log: $(OUTDIR)/connect4_$(UI_TESTING).elf + ./$< -o $@ -c $(TEST_COLUMNS) -r $(TEST_ROWS) --random-moves + +# Log of testing slow logic +test.log.slow: $(OUTDIR)/connect4_$(UI_TESTING).elf + ./$< -o $@ -c $(TEST_COLUMNS) -r $(TEST_ROWS) --random-moves --slow-calcWins + # Compile specifically the ncurses version # This one's special because it needs -lncursesw $(OUTDIR)/connect4_ncurses.elf: $(addprefix $(OBJDIR)/,ui_ncurses.o logic.o connect4.o LICENSE.o)