forked from exercism/ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
36 lines (30 loc) · 1.08 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
# assignments
ASSIGNMENT ?= ""
IGNOREDIRS := "^(\.git|bin|docs|lib|exercises)$$"
ASSIGNMENTS = $(shell find ./exercises -maxdepth 1 -mindepth 1 -type d | awk -F/ '{print $$NF}' | sort | grep -Ev $(IGNOREDIRS))
default: test
# output directories
TMPDIR ?= "/tmp/"
OUTDIR := $(shell mktemp -d "$(TMPDIR)$(ASSIGNMENT).XXXXXXXXXX")
# language specific config (tweakable per language)
FILEEXT := "rb"
EXAMPLE := "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/$(ASSIGNMENT)/* $(OUTDIR)
@cp ./exercises/$(ASSIGNMENT)/$(EXAMPLE) $(OUTDIR)/$(SRCFILE).$(FILEEXT)
@ruby -I./lib -rdisable_skip.rb $(OUTDIR)/$(TSTFILE) $(ARGS)
@rm -rf $(OUTDIR)
# all tests
test:
@for assignment in $(ASSIGNMENTS); do \
ASSIGNMENT=$$assignment $(MAKE) -s test-assignment || exit 1;\
done