blob: 527d7ed86e7f71db73069bb253e4f728959e1359 (
plain)
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
|
CXX := g++
CXXFLAGS := -std=c++11 -Wall -Wextra -Wpedantic -O2
TARGET := triplet
SOURCE := main.cc
HEADER := Triplet.hh
.PHONY: build test
build: $(TARGET)
$(TARGET): $(SOURCE) $(HEADER)
$(CXX) $(CXXFLAGS) $(SOURCE) -o $(TARGET)
test: build
@passed=0; \
failed=0; \
total=0; \
for input in *.in; do \
if [ ! -f "$$input" ]; then \
continue; \
fi; \
total=$$((total + 1)); \
base=$${input%.in}; \
expected="$$base.out"; \
actual="$$base.actual"; \
if [ ! -f "$$expected" ]; then \
echo "[FAIL] $$input: missing $$expected"; \
failed=$$((failed + 1)); \
continue; \
fi; \
if ./$(TARGET) < "$$input" > "$$actual"; then \
if diff -u "$$expected" "$$actual" > /dev/null; then \
echo "[PASS] $$base"; \
passed=$$((passed + 1)); \
else \
echo "[FAIL] $$base"; \
diff -u "$$expected" "$$actual" || true; \
failed=$$((failed + 1)); \
fi; \
else \
echo "[FAIL] $$base: program exited with an error"; \
failed=$$((failed + 1)); \
fi; \
rm -f "$$actual"; \
done; \
echo; \
echo "Passed: $$passed / $$total"; \
if [ "$$failed" -ne 0 ]; then \
exit 1; \
fi
|