Makefile 4.99 KB
Newer Older
1
CXX?=g++
Mikaël Salson's avatar
Mikaël Salson committed
2
INCLUDE=-I ..
3
OPTIM=-g -O0 $(COVERAGE)
Mathieu Giraud's avatar
Mathieu Giraud committed
4
override CXXFLAGS += -std=c++11 -W -Wall $(OPTIM)
5
LDLIBS=-lz
6
SRC= unit-tests/tests.cpp
Mikaël Salson's avatar
Mikaël Salson committed
7
EXEC=$(SRC:.cpp=)
8
OBJ=$(SRC:.cpp=.o)
9
OTHER_SRC=$(wildcard unit-tests/*.cpp)
10
LIB=../core/vidjil.a ../lib/lib.a
11
SHOULD=$(wildcard should-get-tests/*.should-get) $(wildcard bugs/*.should-get)
12
SHOULD_LOG=$(SHOULD:.should-get=.tap)
13
SHOULD_VDJ_EXPECTED_FAILS=--expected-fails 84
14
SHOULD_LOCUS_EXPECTED_FAILS=--expected-fails 2
15
SHOULD_VDJ=$(wildcard should-vdj-tests/*.should-vdj.fa)
16
SHOULD_VDJ_VDJ=$(SHOULD_VDJ:.should-vdj.fa=.1.vdj)
17
SHOULD_LOCUS=$(wildcard should-vdj-tests/*.should-locus.fa)
18
SHOULD_VDJ_TO_TAP=python -u should-vdj-to-tap.py
19
REPORTS_PATH := $(patsubst %/Makefile,%,$(abspath $(lastword $(MAKEFILE_LIST))))/../../reports
20
VALGRIND=valgrind -v --tool=memcheck --leak-check=full --show-reachable=yes --undef-value-errors=yes --track-origins=yes --xml=yes --xml-file="$$(mktemp "$(REPORTS_PATH)/valgrind.xml.XXXXXX")"
Mikaël Salson's avatar
Mikaël Salson committed
21

22
#should-vdj that should not be published in our public curated dataset (just internal tests)
23
EXCLUDE_SHOULD_VDJ=bug20151006-rc.should-vdj.fa cdr3-indels.should-vdj.fa ext-nucleotides-N.should-vdj.fa segment_simul.should-vdj.fa trd-dd2-dd3.should-vdj.fa trd-dd2up-dd3down.should-vdj.fa igh-vdj.should-vdj.fa Demo-X5.should-vdj.fa
24
25
SHOULD_VDJ_ARCHIVE:=$(filter-out $(addprefix should-vdj-tests/,$(EXCLUDE_SHOULD_VDJ)), $(SHOULD_VDJ))

26
DATE=$(shell date +%Y-%m-%d--%H:%M:%S)
27
GIT_SHA1=$(shell git rev-parse --short HEAD || echo 'nogit')
28
SNAPSHOTS_DIR=./snapshots
29
SNAPSHOT=$(SNAPSHOTS_DIR)/snapshot-log--$(DATE)--$(GIT_SHA1)
30
SNAPSHOT_CURRENT=$(SNAPSHOT)--current
31

Mikaël Salson's avatar
Mikaël Salson committed
32
.PHONY: all force clean forcedep
Mikaël Salson's avatar
Mikaël Salson committed
33
34
35
36

test: all
	@echo
	@echo "*** Launching unit tests..."
37
38
	./unit-tests/tests
	cat ./unit-tests/tests.cpp.tap
Mikaël Salson's avatar
Mikaël Salson committed
39
40
41
42
43
	@echo "*** All unit tests passed"

all: core $(EXEC)
	@echo "All tests compiled."

44
snapshot:
45
	mkdir -p $(SNAPSHOTS_DIR)
46
	-grep --no-messages . out-*.log should-get-tests/*.log should-vdj-tests/*.log > $(SNAPSHOT)
47
48

snapshot_success: snapshot
49
50
	touch snapshot-last ; mv snapshot-last snapshot-prev
	ln -s $(SNAPSHOT) snapshot-last
51
	-(which diffstat && make snapshot_diff | diffstat -cC)
52

53
# Diff between the two last succeeded snasphots
54
55
snapshot_diff:
	-diff -u -I ".*20..-..-...*" snapshot-prev snapshot-last
56

57
58
59
60
61
# Diff between the last succeeded snasphot and the (possibly failed) current snapshot
snapshot_diff_current:
	-make snapshot SNAPSHOT="$(SNAPSHOT_CURRENT)"
	-diff -u -I ".*20..-..-...*" snapshot-last $(SNAPSHOT_CURRENT)

62
should: vidjil $(SHOULD_LOG)
Mikaël Salson's avatar
Mikaël Salson committed
63

64
shouldvdj_if_python:
65
	if python ../../tools/check_python_version.py ; \
66
	then $(MAKE) shouldlocus_and_vdj ; \
67
68
	else echo "!!! Bad python version, we skip .should-vdj.fa tests..." ; \
	fi
69

70
71
72
shouldlocus: vidjil
	$(SHOULD_VDJ_TO_TAP) -2q -r $(SHOULD_LOCUS_EXPECTED_FAILS) $(SHOULD_VDJ) $(SHOULD_LOCUS)

73
shouldlocus_and_vdj: vidjil
74
	@echo "*** Launching .should-vdj-fa tests..."
75
	$(MAKE) shouldlocus
76
	$(MAKE) shouldvdj_with_rc
77
	@echo "*** All .should-vdj.fa tests passed"
78

79
80
81
shouldvdj_no_relaunch:
	$(SHOULD_VDJ_TO_TAP) $(SHOULD_VDJ_EXPECTED_FAILS) $(SHOULD_VDJ_VDJ)

82
shouldvdj:
83
	$(SHOULD_VDJ_TO_TAP) $(SHOULD_VDJ_EXPECTED_FAILS) $(SHOULD_VDJ)
84

85
shouldvdj_with_rc:
86
	$(SHOULD_VDJ_TO_TAP) $(SHOULD_VDJ_EXPECTED_FAILS) -r $(SHOULD_VDJ)
87

88
89
shouldvdj_with_rc_merged:
	cat $(SHOULD_VDJ) > should-vdj-tests/should-vdj.merged.fa
90
	$(SHOULD_VDJ_TO_TAP) -r should-vdj-tests/should-vdj.merged.fa
91

92
93
94
# When the global test suite is passing, individual failed tests (counted in SHOULD_*_EXPECTED_FAILS)
# can be marked as 'TODO' to make continuous integration happy
mark_failed_tests_as_todo:
95
	-sed -e "s/^\(not ok [0-9]*\) /\1 # TODO ##/" -i".bak" */*.tap
96
	rm -f */*.tap.bak
97

98
99
curatedvdj_archive: curated-vdj.zip
curated-vdj.zip: $(SHOULD_VDJ_ARCHIVE)
100
	$(eval tmpdir := $(shell mktemp -d))
101
102
	mkdir $(tmpdir)/curated-vdj
	cp --preserve $(SHOULD_VDJ_ARCHIVE) $(tmpdir)/curated-vdj
103
	sed -r 's/\s*BUG//' -i $(tmpdir)/curated-vdj/*
104
105
	for file in $(tmpdir)/curated-vdj/*; do mv $$file `echo $$file | sed 's/should/curated/'`; done
	cwd=`pwd` && cd $(tmpdir) && zip $$cwd/$@ curated-vdj/*
106
107
	rm -rf $(tmpdir)

108
%.tap: %.should-get force
Mikaël Salson's avatar
Mikaël Salson committed
109
	./should-to-tap.sh $<
110
111

valgrind_should:
Mikaël Salson's avatar
Mikaël Salson committed
112
113
	$(MAKE) -C $(REPORTS_PATH) clean_valgrind
	LAUNCHER="$(VALGRIND)" $(MAKE) should
114

115
valgrind_%:
Mikaël Salson's avatar
Mikaël Salson committed
116
	LAUNCHER="$(VALGRIND)" $(MAKE) $(patsubst valgrind_%,%,$@)
117

118
valgrind_tests: vidjil ./unit-tests/tests
119
	$(VALGRIND) ./unit-tests/tests
Mikaël Salson's avatar
Mikaël Salson committed
120

Mathieu Giraud's avatar
Mathieu Giraud committed
121
$(EXEC): % : %.o $(LIB) 
122
	$(CXX) -o $@ $< $(LIB) $(LDLIBS) $(LDFLAGS) $(CXXFLAGS)
Mikaël Salson's avatar
Mikaël Salson committed
123
124


125
126
../%.a:
	$(MAKE) -C $(dir $@) $(notdir $@)
Mikaël Salson's avatar
Mikaël Salson committed
127

128
vidjil:
Mikaël Salson's avatar
Mikaël Salson committed
129
130
	$(MAKE) -C ../ clean
	$(MAKE) -C ../ OPTIM="$(OPTIM)"
131

Mikaël Salson's avatar
Mikaël Salson committed
132
core:
Mikaël Salson's avatar
Mikaël Salson committed
133
	$(MAKE) -C ../core
Mikaël Salson's avatar
Mikaël Salson committed
134

Mathieu Giraud's avatar
Mathieu Giraud committed
135
%.o: %.cpp $(OTHER_SRC)
136
	$(CXX) -o $@ $(INCLUDE) -c $< $(CXXFLAGS)
Mikaël Salson's avatar
Mikaël Salson committed
137
138

clean:
139
	rm -f $(OBJ) $(EXEC)
140
141
cleancoverage:
	rm -f *.gcda *.gcno *.gcov
142
cleantests:
143
	rm -f *.tap *.log should-vdj-tests/*.tap should-vdj-tests/*.log should-get-tests/*.tap should-get-tests/*.log
144
145
146
	rm -rf out/

cleanall: clean cleancoverage cleantests
147

Mikaël Salson's avatar
Mikaël Salson committed
148
forcedep:
149
	$(CXX) $(CXXFLAGS) $(INCLUDE) -M $(SRC) > dep.mk
Mikaël Salson's avatar
Mikaël Salson committed
150

Mikaël Salson's avatar
Mikaël Salson committed
151
152
force:

Mikaël Salson's avatar
Mikaël Salson committed
153
154
155
DEP=$(wildcard dep.mk)

ifeq (${DEP},)
156
$(shell	$(CXX) $(CXXFLAGS) $(INCLUDE) -M $(SRC) > dep.mk)
Mikaël Salson's avatar
Mikaël Salson committed
157
158
159
endif
include dep.mk