2020-08-07 18:37:28 +03:00
|
|
|
############################################
|
|
|
|
# Preamble
|
|
|
|
############################################
|
|
|
|
|
2020-12-21 18:15:42 +03:00
|
|
|
BLACK := $(shell tput -Txterm setaf 0)
|
|
|
|
RED := $(shell tput -Txterm setaf 1)
|
|
|
|
GREEN := $(shell tput -Txterm setaf 2)
|
|
|
|
YELLOW := $(shell tput -Txterm setaf 3)
|
|
|
|
LIGHTPURPLE := $(shell tput -Txterm setaf 4)
|
|
|
|
PURPLE := $(shell tput -Txterm setaf 5)
|
|
|
|
BLUE := $(shell tput -Txterm setaf 6)
|
|
|
|
WHITE := $(shell tput -Txterm setaf 7)
|
|
|
|
|
|
|
|
RESET := $(shell tput -Txterm sgr0)
|
|
|
|
|
2020-12-05 19:27:08 +03:00
|
|
|
CATALA_OPTS?=
|
|
|
|
|
2021-02-01 22:09:16 +03:00
|
|
|
CATALA=dune exec --no-buffer --no-print-director ../src/catala/catala.exe -- Interpret $(CATALA_OPTS)
|
2020-08-07 18:37:28 +03:00
|
|
|
|
2021-01-25 09:09:51 +03:00
|
|
|
pass_tests: $(wildcard */*/output/*.out)
|
2020-12-10 11:27:51 +03:00
|
|
|
|
2021-01-25 09:09:51 +03:00
|
|
|
reset_tests: $(subst output/,,$(subst .out,.in,$(wildcard */*/output/*.out)))
|
2020-08-07 18:37:28 +03:00
|
|
|
|
|
|
|
# Forces all the tests to be redone
|
|
|
|
.FORCE:
|
|
|
|
|
2020-12-09 19:31:42 +03:00
|
|
|
%.run: .FORCE
|
|
|
|
$(CATALA) $(word 1,$(subst ., ,$*)).catala -s $(word 3,$(subst ., ,$*))
|
|
|
|
|
2021-01-24 04:26:10 +03:00
|
|
|
# Usage: make <test_dir>/output/<test_name>.catala.<scope_name>.out
|
2020-12-06 19:48:15 +03:00
|
|
|
# This rule runs the test and compares against the expected output. If the
|
2021-01-25 09:09:51 +03:00
|
|
|
# Catala program is <test_dir>/<test_name>.catala
|
2021-01-24 04:26:10 +03:00
|
|
|
# and the scope to run is <scope_name>, then the expected output should be in the file
|
|
|
|
# <test_dir>/output/<test_name>.catala.<scope_name>.out
|
2020-12-06 19:48:15 +03:00
|
|
|
%.out: .FORCE
|
2021-01-25 09:09:51 +03:00
|
|
|
@$(CATALA) --unstyled \
|
|
|
|
$(word 1, $(subst /, , $*))/$(word 2, $(subst /, , $*))/$(word 1, $(subst ., ,$(word 4, $(subst /, , $*)))).catala \
|
2021-01-24 04:49:17 +03:00
|
|
|
-s $(word 3, $(subst ., ,$*)) 2>&1 | \
|
|
|
|
colordiff -u -b $@ - || { echo "${RED}FAIL${RESET} ${PURPLE}$*${RESET}"; exit 1; }
|
2020-12-21 18:15:42 +03:00
|
|
|
@echo "${GREEN}PASS${RESET} ${PURPLE}$*${RESET}"
|
2020-12-06 19:48:15 +03:00
|
|
|
|
2021-01-25 09:09:51 +03:00
|
|
|
# Usage: make <test_dir>/<test_name>.catala.<scope_name>.in
|
|
|
|
# This rule runs the test <test_dir>/<test_name>.catala, prints its output and
|
2021-01-24 04:26:10 +03:00
|
|
|
# writes this output to the <test_dir>/output/<test_name>.catala.<scope_name>.out file
|
2020-12-06 19:48:15 +03:00
|
|
|
%.in: .FORCE
|
2021-01-25 09:09:51 +03:00
|
|
|
@-$(CATALA) $(word 1,$(subst ., ,$*)).catala -s $(word 3,$(subst ., ,$*))
|
|
|
|
@-$(CATALA) --unstyled $(word 1,$(subst ., ,$*)).catala -s $(word 3,$(subst ., ,$*)) \
|
|
|
|
> $(dir $*)output/$(lastword $(subst /, ,$*)).out 2>&1
|