Skip to content

Commit da50bcf

Browse files
committed
Cleanup dependencies in unit test builds, check number of tests
1 parent a608875 commit da50bcf

File tree

4 files changed

+36
-25
lines changed

4 files changed

+36
-25
lines changed

jbmc/unit/Makefile

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all cprover.dir jprover.dir testing-utils.dir java-testing-utils.dir test
1+
.PHONY: all jprover.dir test
22

33
# Source files for test utilities
44
SRC = $(CPROVER_DIR)/unit/unit_tests.cpp \
@@ -64,16 +64,13 @@ include ../src/config.inc
6464
include $(CPROVER_DIR)/src/config.inc
6565
include $(CPROVER_DIR)/src/common
6666

67-
cprover.dir:
68-
$(MAKE) $(MAKEARGS) -C $(CPROVER_DIR)/src
69-
7067
jprover.dir:
7168
$(MAKE) $(MAKEARGS) -C ../src
7269

73-
cprover-testing-utils.dir:
70+
$(CPROVER_DIR)/unit/testing-utils/testing-utils$(LIBEXT): jprover.dir
7471
$(MAKE) $(MAKEARGS) -C $(CPROVER_DIR)/unit/testing-utils
7572

76-
java-testing-utils.dir:
73+
java-testing-utils/java-testing-utils$(LIBEXT): jprover.dir
7774
$(MAKE) $(MAKEARGS) -C java-testing-utils
7875

7976
# We need to link bmc.o to the unit test, so here's everything it depends on...
@@ -126,16 +123,21 @@ OBJ += $(CPROVER_LIBS) \
126123
$(CPROVER_DIR)/unit/testing-utils/testing-utils$(LIBEXT) \
127124
java-testing-utils/java-testing-utils$(LIBEXT)
128125

129-
TESTS = unit_tests$(EXEEXT) \
130-
# Empty last line
126+
CATCH_TEST = unit_tests$(EXEEXT)
127+
N_CATCH_TESTS = 84
128+
129+
CLEANFILES = $(CATCH_TEST) java-testing-utils/java-testing-utils$(LIBEXT)
131130

132-
CLEANFILES = $(TESTS)
131+
# only add a dependency for libraries to avoid triggering implicit rules, which
132+
# would cause unnecessary rebuilds
133+
$(filter %$(LIBEXT), CPROVER_LIBS): jprover.dir
133134

134-
all: cprover.dir cprover-testing-utils.dir jprover.dir java-testing-utils.dir
135-
$(MAKE) $(MAKEARGS) $(TESTS)
135+
all: $(CATCH_TEST)
136136

137-
test: all
138-
$(foreach test,$(TESTS), (echo Running: $(test); ./$(test)) &&) true
137+
test: $(CATCH_TEST)
138+
if ! ./$(CATCH_TEST) -l | grep -q "^$(N_CATCH_TESTS) test cases$$" ; then \
139+
./$(CATCH_TEST) -l ; fi
140+
./$(CATCH_TEST)
139141

140142

141143
###############################################################################

src/ansi-c/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ cprover_library.inc: library/converter$(EXEEXT) library/*.c
115115
%.inc: %.h file_converter$(EXEEXT)
116116
./file_converter$(EXEEXT) < $< > $@
117117

118-
cprover_library.cpp: cprover_library.inc
119-
120118
ansi_c_internal_additions$(OBJEXT): $(BUILTIN_FILES)
121119

122120
generated_files: \

src/cpp/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ all: cpp$(LIBEXT)
5959

6060
###############################################################################
6161

62+
# extra dependencies
63+
cprover_library$(OBJEXT): cprover_library.inc
64+
65+
###############################################################################
66+
6267
../ansi-c/library/converter$(EXEEXT): ../ansi-c/library/converter.cpp
6368
$(MAKE) -C ../ansi-c library/converter$(EXEEXT)
6469

@@ -69,8 +74,6 @@ library_check: library/*.c
6974
cprover_library.inc: ../ansi-c/library/converter$(EXEEXT) library/*.c
7075
cat library/*.c | ../ansi-c/library/converter$(EXEEXT) > $@
7176

72-
cprover_library.cpp: cprover_library.inc
73-
7477
generated_files: cprover_library.inc
7578

7679
###############################################################################

unit/Makefile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all cprover.dir testing-utils.dir test
1+
.PHONY: all cprover.dir test
22

33
# Source files for test utilities
44
SRC = unit_tests.cpp \
@@ -56,7 +56,7 @@ include ../src/common
5656
cprover.dir:
5757
$(MAKE) $(MAKEARGS) -C ../src
5858

59-
testing-utils.dir:
59+
testing-utils/testing-utils$(LIBEXT): cprover.dir
6060
$(MAKE) $(MAKEARGS) -C testing-utils
6161

6262
# We need to link bmc.o to the unit test, so here's everything it depends on...
@@ -97,17 +97,25 @@ CPROVER_LIBS =../src/ansi-c/ansi-c$(LIBEXT) \
9797

9898
OBJ += $(CPROVER_LIBS) testing-utils/testing-utils$(LIBEXT)
9999

100-
TESTS = unit_tests$(EXEEXT) \
101-
miniBDD$(EXEEXT) \
100+
CATCH_TEST = unit_tests$(EXEEXT)
101+
N_CATCH_TESTS = 62
102+
103+
TESTS = miniBDD$(EXEEXT) \
102104
# Empty last line
103105

104-
CLEANFILES = $(TESTS)
106+
CLEANFILES = $(CATCH_TEST) $(TESTS) testing-utils/testing-utils$(LIBEXT)
107+
108+
# only add a dependency for libraries to avoid triggering implicit rules, which
109+
# would cause unnecessary rebuilds
110+
$(filter %$(LIBEXT), CPROVER_LIBS): cprover.dir
105111

106-
all: cprover.dir testing-utils.dir
107-
$(MAKE) $(MAKEARGS) $(TESTS)
112+
all: $(CATCH_TEST) $(TESTS)
108113

109-
test: all
114+
test: $(CATCH_TEST) $(TESTS)
110115
$(foreach test,$(TESTS), (echo Running: $(test); ./$(test)) &&) true
116+
if ! ./$(CATCH_TEST) -l | grep -q "^$(N_CATCH_TESTS) test cases$$" ; then \
117+
./$(CATCH_TEST) -l ; fi
118+
./$(CATCH_TEST)
111119

112120

113121
###############################################################################

0 commit comments

Comments
 (0)