Skip to content

Commit 2f019b0

Browse files
authored
Merge pull request #1314 from stan-dev/cleanup-test-dependencies
Clean up test makefile dependencies
2 parents 7767566 + 323f9d9 commit 2f019b0

File tree

6 files changed

+41
-60
lines changed

6 files changed

+41
-60
lines changed

make/tests

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,11 @@ test/%$(EXE) : INC += $(INC_GTEST) -I $(RAPIDJSON)
88
test/%$(EXE) : test/%.o $(GTEST)/src/gtest_main.cc $(GTEST)/src/gtest-all.o $(SUNDIALS_TARGETS) $(MPI_TARGETS) $(TBB_TARGETS)
99
$(LINK.cpp) $(filter-out src/test/test-models/% src/%.csv bin/% test/%.hpp %.hpp-test,$^) $(LDLIBS) $(OUTPUT_OPTION)
1010

11-
.PRECIOUS: test/%.o
12-
test/%.o : src/test/%.cpp src/test/utility.hpp $(wildcard src/cmdstan/*.hpp)
11+
# generates .d files as a side effect
12+
test/%.o : src/test/%.cpp src/test/utility.hpp
1313
@mkdir -p $(dir $@)
14-
$(COMPILE.cpp) $< $(OUTPUT_OPTION)
14+
$(COMPILE.cpp) -MT $@ -MMD -MP -MF test/$*.d $(OUTPUT_OPTION) $<
1515

16-
##
17-
# Customization for generating dependencies
18-
##
19-
src/test/%.d : src/test/%.hpp
20-
src/test/%.d : CXXFLAGS += $(CXXFLAGS_GTEST)
21-
src/test/%.d : CPPFLAGS += $(CPPFLAGS_GTEST)
22-
src/test/%.d : INC += $(INC_GTEST)
23-
src/test/%.d : test/%.o
24-
25-
ifneq ($(filter test/%,$(MAKECMDGOALS)),)
26-
-include $(patsubst test/%$(EXE),src/test/%.d,$(filter test/%,$(MAKECMDGOALS)))
27-
endif
2816

2917
############################################################
3018
#
@@ -43,49 +31,56 @@ endif
4331
$(COMPILE.cpp) -O0 -include $^ -o $(DEV_NULL)
4432

4533
test/dummy.cpp:
46-
@mkdir -p test
4734
@touch $@
4835
@echo "int main() {return 0;}" >> $@
4936

5037
.PHONY: test-headers
5138
test-headers: $(HEADER_TESTS)
5239

53-
############################################################
54-
#
55-
# Target to generate C++ code for all test-models
56-
##
57-
TEST_MODELS := $(wildcard src/test/test-models/*.stan)
40+
ifneq ($(filter test/%,$(MAKECMDGOALS)),)
5841

59-
ifneq ($(filter test-models-hpp,$(MAKECMDGOALS)),)
60-
-include $(patsubst %.stan,%.d,$(TEST_MODELS))
6142
include src/cmdstan/main.d
62-
endif
6343

64-
.PHONY: test-models-hpp
65-
test-models-hpp: $(patsubst %.stan,%.hpp,$(TEST_MODELS)) $(patsubst %.stan,%$(EXE),$(TEST_MODELS))
44+
TEST_SRCS = $(wildcard src/test/interface/*.cpp)
45+
TEST_DEPFILES := $(TEST_SRCS:src/test/%.cpp=test/%.d)
46+
$(TEST_DEPFILES):
47+
include $(wildcard $(TEST_DEPFILES))
48+
endif
6649

6750
##
6851
# Tests that depend on compiled models
6952
##
70-
test/interface/generated_quantities_test$(EXE): $(addsuffix $(EXE),$(addprefix src/test/test-models/, bern_gq_model bern_extra_model test_model))
71-
test/interface/log_prob_test$(EXE): $(addsuffix $(EXE),$(addprefix src/test/test-models/, bern_log_prob_model bern_gq_model simplex_model))
72-
test/interface/laplace_test$(EXE): $(addsuffix $(EXE),$(addprefix src/test/test-models/, multi_normal_model simple_jacobian_model simplex_model))
73-
test/interface/pathfind_test$(EXE): $(addsuffix $(EXE),$(addprefix src/test/test-models/, multi_normal_model eight_schools))
74-
test/interface/command_test$(EXE): $(addsuffix $(EXE),$(addprefix src/test/test-models/, printer domain_fail proper value_fail transformed_data_rng_test ndim_array))
75-
test/interface/metric_test$(EXE): $(addsuffix $(EXE),$(addprefix src/test/test-models/, test_model proper))
76-
test/interface/csv_header_consistency_test$(EXE): src/test/test-models/csv_header_consistency$(EXE)
77-
test/interface/diagnose_test$(EXE): bin/diagnose$(EXE)
78-
test/interface/elapsed_time_test$(EXE): src/test/test-models/test_model$(EXE)
79-
test/interface/fixed_param_sampler_test$(EXE): $(addsuffix $(EXE),$(addprefix src/test/test-models/, empty proper))
80-
test/interface/mpi_test$(EXE): $(addsuffix $(EXE),$(addprefix src/test/test-models/, proper))
81-
test/interface/model_output_test$(EXE): src/test/test-models/printer$(EXE)
82-
test/interface/optimization_output_test$(EXE): src/test/test-models/optimization_output$(EXE)
83-
test/interface/print_test$(EXE): bin/print$(EXE)
84-
test/interface/print_uninitialized_test$(EXE): src/test/test-models/print_uninitialized$(EXE)
85-
test/interface/arguments/argument_configuration_test$(EXE): src/test/test-models/test_model$(EXE)
86-
test/interface/stansummary_test$(EXE): bin/stansummary$(EXE)
87-
test/interface/variational_output_test$(EXE): src/test/test-models/variational_output$(EXE)
53+
define depends_on_test_models
54+
| $(addsuffix $(EXE),$(addprefix src/test/test-models/,$(1)))
55+
endef
8856

57+
test/interface/command_test$(EXE): $(call depends_on_test_models, printer domain_fail proper value_fail transformed_data_rng_test ndim_array)
58+
test/interface/config_json_test$(EXE): $(call depends_on_test_models, multi_normal_model)
59+
test/interface/csv_header_consistency_test$(EXE): $(call depends_on_test_models, csv_header_consistency)
60+
test/interface/datetime_test$(EXE): $(call depends_on_test_models, test_model)
61+
test/interface/elapsed_time_test$(EXE): $(call depends_on_test_models, test_model)
62+
test/interface/fixed_param_sampler_test$(EXE): $(call depends_on_test_models, empty proper)
63+
test/interface/generated_quantities_test$(EXE): $(call depends_on_test_models, bern_gq_model bern_extra_model gq_non_scalar test_model)
64+
test/interface/laplace_test$(EXE): $(call depends_on_test_models, multi_normal_model simple_jacobian_model simplex_model)
65+
test/interface/log_prob_test$(EXE): $(call depends_on_test_models, bern_log_prob_model bern_gq_model simplex_model)
66+
test/interface/metric_test$(EXE): $(call depends_on_test_models, test_model proper)
67+
test/interface/model_output_test$(EXE): $(call depends_on_test_models, printer)
68+
test/interface/multi_chain_init_test$(EXE): $(call depends_on_test_models, bern_gq_model)
69+
test/interface/multi_chain_test$(EXE): $(call depends_on_test_models, test_model)
70+
test/interface/optimization_output_test$(EXE): $(call depends_on_test_models, optimization_output simple_jacobian_model)
71+
test/interface/output_sig_figs_test$(EXE): $(call depends_on_test_models, proper_sig_figs)
72+
test/interface/pathfinder_test$(EXE): $(call depends_on_test_models, multi_normal_model eight_schools empty)
73+
test/interface/print_uninitialized_test$(EXE): $(call depends_on_test_models, print_uninitialized)
74+
test/interface/save_metric_json_test$(EXE): $(call depends_on_test_models, simplex_model multi_normal_model)
75+
test/interface/variational_output_test$(EXE): $(call depends_on_test_models, variational_output)
76+
77+
# these tests depend only on the bin/ executables, not any models
78+
test/interface/stansummary_test$(EXE): bin/stansummary$(EXE)
79+
test/interface/diagnose_test$(EXE): bin/diagnose$(EXE)
80+
test/interface/print_test$(EXE): bin/print$(EXE)
81+
82+
83+
TEST_MODELS := $(wildcard src/test/test-models/*.stan)
8984
.PHONY: clean-tests
9085
clean-tests:
9186
$(RM) -r test

runCmdStanTests.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,6 @@ def makeBuild(j):
7777
doCommand(command)
7878

7979

80-
def makeTestModels(j):
81-
if j == None:
82-
command = 'make test-models-hpp'
83-
else:
84-
command = 'make -j%d test-models-hpp' % j
85-
doCommand(command)
86-
8780
def makeMathLibs(j):
8881
if j == None:
8982
command = 'make -f stan/lib/stan_math/make/standalone math-libs'
@@ -176,7 +169,6 @@ def main():
176169
makeBuild(j)
177170
if (isWin()):
178171
makeMathLibs(j)
179-
makeTestModels(j)
180172

181173
# pass 1: call make to compile test targets
182174
for i in range(argsIdx,len(sys.argv)):

src/test/interface/command_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#include <cmdstan/command.hpp>
2-
#include <test/test-models/proper.hpp>
31
#include <test/utility.hpp>
2+
#include <cmdstan/return_codes.hpp>
43
#include <stan/callbacks/stream_writer.hpp>
54
#include <stan/services/error_codes.hpp>
65
#include <boost/algorithm/string.hpp>

src/test/interface/metric_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#include <cmdstan/command.hpp>
21
#include <stan/callbacks/stream_writer.hpp>
2+
#include <cmdstan/return_codes.hpp>
33
#include <stan/services/error_codes.hpp>
4-
#include <test/test-models/proper.hpp>
54
#include <test/utility.hpp>
65
#include <boost/math/policies/error_handling.hpp>
76
#include <gtest/gtest.h>

src/test/interface/mpi_test.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#ifdef STAN_MPI
22

3-
#include <test/test-models/proper.hpp>
4-
#include <cmdstan/command.hpp>
53
#include <stan/math/prim.hpp>
64
#include <gtest/gtest.h>
75

src/test/interface/tbb_threadpool_test.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include <cmdstan/command.hpp>
2-
#include <test/test-models/proper.hpp>
31
#include <stan/math/prim/core/init_threadpool_tbb.hpp>
42
#include <gtest/gtest.h>
53

0 commit comments

Comments
 (0)