Makefile 4.39 KB
Newer Older
1
CXX?=g++
Mikaël Salson's avatar
Mikaël Salson committed
2
INCLUDE=-I ..
3
OPTIM=-g -O0 $(COVERAGE)
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 12
SHOULD=$(wildcard should-get-tests/*.should-get)
SHOULD_LOG=$(SHOULD:.should-get=.tap)
13 14
SHOULD_VDJ_EXPECTED_FAILS=--expected-fails 84
SHOULD_LOCUS_EXPECTED_FAILS=--expected-fails 3
15
SHOULD_VDJ=$(wildcard should-vdj-tests/*.should-vdj.fa)
16
SHOULD_LOCUS=$(wildcard should-vdj-tests/*.should-locus.fa)
17
SHOULD_VDJ_TO_TAP=python -u should-vdj-to-tap.py
18
REPORTS_PATH := $(patsubst %/Makefile,%,$(abspath $(lastword $(MAKEFILE_LIST))))/../../reports
19
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
20

21
#should-vdj that should not be published in our public curated dataset (just internal tests)
22
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
23 24
SHOULD_VDJ_ARCHIVE:=$(filter-out $(addprefix should-vdj-tests/,$(EXCLUDE_SHOULD_VDJ)), $(SHOULD_VDJ))

25
DATE=$(shell date +%Y-%m-%d--%H:%M:%S)
26
SNAPSHOTS_DIR=./snapshots
27
SNAPSHOT=$(SNAPSHOTS_DIR)/snapshot-log--$(DATE)
28
SNAPSHOT_CURRENT=$(SNAPSHOT)--current
29

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

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

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

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

snapshot_success: snapshot
47 48
	touch snapshot-last ; mv snapshot-last snapshot-prev
	ln -s $(SNAPSHOT) snapshot-last
49 50
	make snapshot_diff | diffstat -cC

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

55 56 57 58 59
# 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)

60
should: vidjil $(SHOULD_LOG)
Mikaël Salson's avatar
Mikaël Salson committed
61

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

68
shouldlocus_and_vdj: vidjil
69
	@echo "*** Launching .should-vdj-fa tests..."
70
	$(SHOULD_VDJ_TO_TAP) -2q -r $(SHOULD_LOCUS_EXPECTED_FAILS) $(SHOULD_VDJ) $(SHOULD_LOCUS)
71
	$(MAKE) shouldvdj_with_rc
72
	@echo "*** All .should-vdj.fa tests passed"
73

74
shouldvdj:
75
	$(SHOULD_VDJ_TO_TAP) $(SHOULD_VDJ_EXPECTED_FAILS) $(SHOULD_VDJ)
76

77
shouldvdj_with_rc:
78
	$(SHOULD_VDJ_TO_TAP) $(SHOULD_VDJ_EXPECTED_FAILS) -r $(SHOULD_VDJ)
79

80 81
shouldvdj_with_rc_merged:
	cat $(SHOULD_VDJ) > should-vdj-tests/should-vdj.merged.fa
82
	$(SHOULD_VDJ_TO_TAP) -r should-vdj-tests/should-vdj.merged.fa
83

84 85
curatedvdj_archive: curated-vdj.zip
curated-vdj.zip: $(SHOULD_VDJ_ARCHIVE)
86
	$(eval tmpdir := $(shell mktemp -d))
87 88 89 90 91
	mkdir $(tmpdir)/curated-vdj
	cp --preserve $(SHOULD_VDJ_ARCHIVE) $(tmpdir)/curated-vdj
	sed -ri 's/\s*BUG//' $(tmpdir)/curated-vdj/*
	for file in $(tmpdir)/curated-vdj/*; do mv $$file `echo $$file | sed 's/should/curated/'`; done
	cwd=`pwd` && cd $(tmpdir) && zip $$cwd/$@ curated-vdj/*
92 93
	rm -rf $(tmpdir)

94
%.tap: %.should-get force
Mikaël Salson's avatar
Mikaël Salson committed
95
	./should-to-tap.sh $<
96 97

valgrind_should:
98 99
	$(MAKE) -C $(REPORTS_PATH) clean_valgrind
	LAUNCHER="$(VALGRIND)" $(MAKE) should
100

101
valgrind_%:
102
	LAUNCHER="$(VALGRIND)" $(MAKE) $(patsubst valgrind_%,%,$@)
103

104
valgrind_tests: vidjil ./unit-tests/tests
105
	$(VALGRIND) ./unit-tests/tests
Mikaël Salson's avatar
Mikaël Salson committed
106

Mathieu Giraud's avatar
Mathieu Giraud committed
107
$(EXEC): % : %.o $(LIB) 
108
	$(CXX) -o $@ $< $(LIB) $(LDLIBS) $(LDFLAGS) $(CXXFLAGS)
Mikaël Salson's avatar
Mikaël Salson committed
109 110 111 112


../core.a: core

113
vidjil:
114 115
	$(MAKE) -C ../ clean
	$(MAKE) -C ../ OPTIM="$(OPTIM)"
116

Mikaël Salson's avatar
Mikaël Salson committed
117
core:
118
	$(MAKE) -C ../core
Mikaël Salson's avatar
Mikaël Salson committed
119

Mathieu Giraud's avatar
Mathieu Giraud committed
120
%.o: %.cpp $(OTHER_SRC)
121
	$(CXX) -o $@ $(INCLUDE) -c $< $(CXXFLAGS)
Mikaël Salson's avatar
Mikaël Salson committed
122 123

clean:
124
	rm -f $(OBJ) $(EXEC)
125 126
cleancoverage:
	rm -f *.gcda *.gcno *.gcov
127
cleantests:
128
	rm -f *.tap *.log should-vdj-tests/*.tap should-vdj-tests/*.log should-get-tests/*.tap should-get-tests/*.log
129 130 131
	rm -rf out/

cleanall: clean cleancoverage cleantests
132

Mikaël Salson's avatar
Mikaël Salson committed
133
forcedep:
134
	$(CXX) $(CXXFLAGS) $(INCLUDE) -M $(SRC) > dep.mk
Mikaël Salson's avatar
Mikaël Salson committed
135

Mikaël Salson's avatar
Mikaël Salson committed
136 137
force:

Mikaël Salson's avatar
Mikaël Salson committed
138 139 140
DEP=$(wildcard dep.mk)

ifeq (${DEP},)
141
$(shell	$(CXX) $(CXXFLAGS) $(INCLUDE) -M $(SRC) > dep.mk)
Mikaël Salson's avatar
Mikaël Salson committed
142 143 144
endif
include dep.mk