-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
55 lines (46 loc) · 1.54 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Por aqui caminho relativo para o codigo
SCRIPT=projeto3.py
# Por aqui caminho relativo para a pasta dos testes
TESTS_DIR=tests
# Daqui para a frente ja nao e preciso mudar nada :)
# ==Comandos==
# make test para correr os testes
# make clean para apagar os resultados
# make checkpy para verificar a versao de python que esta a ser usada
# python3.7 e o usado no mooshak (especificamente 3.7.3)
# se nao estiver presente, python3 sera usado
# ==Resultados==
# Os resultados ficam na pasta test_res, divididos em 4 ficheiros
# 00_diff contem o diff entre o esperado e o obtido
# test_expected_out mostra o resultado esperado
# test_effective_out mostra o resultado obtido
# test_order mostra a ordem pela qual os testes foram corridos
#==Code==
TESTS=$(wildcard $(TESTS_DIR)/*.in)
RESULTS=$(patsubst %.in,%.out,$(TESTS))
PY=python3
ifneq ($(shell which python3.7),)
PY=python3.7
endif
.PHONY: all test clean checkpy
all: test
test:
@echo "Running tests..."
@mkdir -p test_res
@echo "" > test_res/test_effective_out
@-for testfile in $(TESTS) ; do \
$(PY) $(SCRIPT) < $$testfile >> test_res/test_effective_out; \
done
@echo "" > test_res/test_expected_out
@-for resultfile in $(RESULTS) ; do \
cat $$resultfile >> test_res/test_expected_out; \
done
@echo "" > test_res/test_order
@-for testfile in $(TESTS) ; do \
echo $$testfile >> test_res/test_order; \
done
@(diff test_res/test_effective_out test_res/test_expected_out > test_res/00_diff && echo "Tests passed.") || echo "Some tests failed."
clean:
$(RM) -r test_res
checkpy:
@echo $(PY)