@@ -8,23 +8,11 @@ test/%$(EXE) : INC += $(INC_GTEST) -I $(RAPIDJSON)
88test/%$(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
4533test/dummy.cpp:
46- @mkdir -p test
4734 @touch $@
4835 @echo "int main() {return 0;}" >> $@
4936
5037.PHONY: test-headers
5138test-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))
6142include 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
9085clean-tests:
9186 $(RM) -r test
0 commit comments