Skip to content

Commit c7b3b6f

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

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

jbmc/unit/Makefile

Lines changed: 13 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,19 @@ 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+
$(CPROVER_LIBS): jprover.dir
133132

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

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

140140

141141
###############################################################################

unit/Makefile

Lines changed: 14 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,23 @@ 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+
$(CPROVER_LIBS): cprover.dir
105109

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

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

112118

113119
###############################################################################

0 commit comments

Comments
 (0)