@@ -15,12 +15,13 @@ all: sofos
1515.PHONY : default all clean
1616
1717clean :
18- rm -f sofos sofos_debug sofos_unittest sofos_unittest_coverage sofos_coverage
18+ rm -f sofos sofos_debug unittest unittest_coverage sofos_coverage
1919 rm -f * .gcov * .gcda * .gcno
2020 rm -f coverage* .html
2121 rm -f clang-tidy.txt clang-format.patch
2222
2323SOFOSCC =sofos.cc main.cc
24+ UNITCC =sofos.cc unittest.cc
2425SOFOSHPP =sofos.hpp vcf.hpp
2526FORMATFILES =$(SOFOSCC ) $(SOFOSHPP ) test_utils.hpp
2627
@@ -30,24 +31,31 @@ sofos: $(SOFOSCC) $(SOFOSHPP)
3031sofos_debug : $(SOFOSCC ) $(SOFOSHPP )
3132 $(CXX ) -g -O0 $(SOFOSFLAGS ) -o $@ $(SOFOSCC )
3233
33- sofos_coverage : $(SOFOSCC ) $(SOFOSHPP )
34- $(CXX ) -g -O0 $(SOFOSFLAGS ) $( GCOVFLAGS ) -o $@ $(SOFOSCC )
34+ unittest : $(UNITCC ) $(SOFOSHPP )
35+ $(CXX ) -g -O0 $(SOFOSFLAGS ) -DSOFOS_UNIT_TESTS -o $@ $(UNITCC )
3536
36- sofos_unittest : $( SOFOSCC ) $( SOFOSHPP )
37- $(CXX ) -g -O0 $(SOFOSFLAGS ) -DSOFOS_UNIT_TESTS -o $@ $( SOFOSCC )
37+ % _cov.o : % .cc
38+ $(CXX ) -c - g -O0 $(SOFOSFLAGS ) $( GCOVFLAGS ) -o $@ $<
3839
39- sofos_unittest_coverage : $(SOFOSCC ) $(SOFOSHPP )
40- $(CXX ) -g -O0 $(SOFOSFLAGS ) $(GCOVFLAGS ) -DSOFOS_UNIT_TESTS -o $@ $(SOFOSCC )
40+ sofos_cov.o : $(SOFOSHPP )
4141
42- test : sofos_unittest sofos_debug
43- ./sofos_unittest
42+ unit_cov.o : $(SOFOSHPP )
43+
44+ sofos_coverage : $(patsubst % .cc,% _cov.o,$(SOFOSCC ) )
45+ $(CXX ) -g -O0 $(SOFOSFLAGS ) $(GCOVFLAGS ) -o $@ $^
46+
47+ unittest_coverage : $(patsubst % .cc,% _cov.o,$(UNITCC ) )
48+ $(CXX ) -g -O0 $(SOFOSFLAGS ) $(GCOVFLAGS ) -DSOFOS_UNIT_TESTS -o $@ $^
49+
50+ test : unittest sofos_debug
51+ ./unittest
4452 cd test && bash test-01.bash ../sofos_debug
4553
46- coverage : sofos_coverage sofos_unittest_coverage
54+ coverage : sofos_coverage unittest_coverage
4755 rm -f * .gcda
48- ./sofos_unittest_coverage
56+ ./unittest_coverage
4957 cd test && bash test-01.bash ../sofos_coverage
50- gcovr -r . -e catch.hpp -e test_utils.hpp --html-details -o coverage.html
58+ gcovr -r . -e catch.hpp -e unittest.cc --html-details -o coverage.html
5159
5260test_codecov : sofos_unittest_coverage sofos_coverage
5361 rm -f * .gcda
@@ -72,4 +80,4 @@ test_tidy:
7280 @$(CLANGTIDY ) $(SOFOSCC ) -- $(CXXFLAGS ) $(SOFOSFLAGS ) -Wall 2> /dev/null | tee clang-tidy.txt
7381 @test 0 -eq ` cat clang-tidy.txt | wc -l`
7482
75- .PHONY : coverage tidy format test test_codecov test_format
83+ .PHONY : coverage tidy format test test_codecov test_format cov
0 commit comments