-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathMakefile
67 lines (52 loc) · 1.94 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
56
57
58
59
60
61
62
63
64
65
66
67
# assignments
ASSIGNMENT ?= ""
ASSIGNMENTS = $(shell git ls-tree --name-only HEAD -- exercises/practice/ | awk -F/ '{print $$NF}' | sort)
TEMPLATES = $(shell git ls-tree --name-only HEAD -- templates/ | awk -F/ '{print $$NF}' | sort)
ASSIGNMENTS_GEN = $(TEMPLATES:=.gen)
ASSIGNMENTS_DOCKER = $(ASSIGNMENTS:=.docker)
default: testgenerator test
# output directories
TMPDIR ?= "/tmp/"
OUTDIR := $(shell mktemp -d "$(TMPDIR)$(ASSIGNMENT).XXXXXXXXXX")
# language specific config (tweakable per language)
FILEEXT := "ml"
EXAMPLE := ".meta/example.$(FILEEXT)"
SRCFILE := "$(shell echo $(ASSIGNMENT) | sed 's/-/_/g')"
TSTFILE := "$(SRCFILE)_test.$(FILEEXT)"
# Any additional arguments, such as -p for pretty output and others
ARGS ?= ""
# single test
test-assignment:
@echo ""
@echo ""
@echo "----------------------------------------------------------------"
@echo "running tests for: $(ASSIGNMENT)"
@cp -r ./exercises/practice/$(ASSIGNMENT)/* $(OUTDIR)
@cp ./exercises/practice/$(ASSIGNMENT)/$(EXAMPLE) $(OUTDIR)/$(SRCFILE).$(FILEEXT)
@make -C $(OUTDIR)
@rm -rf $(OUTDIR)
# all tests
test:
@for assignment in $(ASSIGNMENTS); do \
ASSIGNMENT=$$assignment $(MAKE) -s test-assignment || exit 1;\
done
build_test: test test_generator
$(ASSIGNMENTS_DOCKER):
@echo "running tests for: $(@:.docker=)"
@./bin/run-in-docker.sh $(@:.docker=)
test-docker: $(ASSIGNMENTS_DOCKER)
generator:
dune build --root=./test-generator/
test_generator: generator
dune runtest --root=./test-generator/
$(ASSIGNMENTS_GEN): test_generator
dune exec ./bin_test_gen/test_gen.exe --root=./test-generator/ -- --exercise $(@:.gen=) --filter-broken true
generate_exercises: $(ASSIGNMENTS_GEN)
install_deps:
opam install dune fpath ocamlfind ounit qcheck react ppx_deriving ppx_let ppx_sexp_conv yojson ocp-indent calendar getopts
clean:
dune clean --root=./test-generator/
@for assignment in $(ASSIGNMENTS); do \
dune clean --root=./exercises/practice/$$assignment;\
done
.PHONY: clean