@@ -8,23 +8,11 @@ test/%$(EXE) : INC += $(INC_GTEST) -I $(RAPIDJSON)
8
8
test/%$(EXE) : test/%.o $(GTEST)/src/gtest_main.cc $(GTEST)/src/gtest-all.o $(SUNDIALS_TARGETS) $(MPI_TARGETS) $(TBB_TARGETS)
9
9
$(LINK.cpp) $(filter-out src/test/test-models/% src/%.csv bin/% test/%.hpp %.hpp-test,$^) $(LDLIBS) $(OUTPUT_OPTION)
10
10
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
13
13
@mkdir -p $(dir $@)
14
- $(COMPILE.cpp) $< $ (OUTPUT_OPTION)
14
+ $(COMPILE.cpp) -MT $@ -MMD -MP -MF test/$*.d $ (OUTPUT_OPTION) $<
15
15
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
28
16
29
17
############################################################
30
18
#
@@ -43,49 +31,56 @@ endif
43
31
$(COMPILE.cpp) -O0 -include $^ -o $(DEV_NULL)
44
32
45
33
test/dummy.cpp:
46
- @mkdir -p test
47
34
@touch $@
48
35
@echo "int main() {return 0;}" >> $@
49
36
50
37
.PHONY: test-headers
51
38
test-headers: $(HEADER_TESTS)
52
39
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)),)
58
41
59
- ifneq ($(filter test-models-hpp,$(MAKECMDGOALS)),)
60
- -include $(patsubst %.stan,%.d,$(TEST_MODELS))
61
42
include src/cmdstan/main.d
62
- endif
63
43
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
66
49
67
50
##
68
51
# Tests that depend on compiled models
69
52
##
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
88
56
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)
89
84
.PHONY: clean-tests
90
85
clean-tests:
91
86
$(RM) -r test
0 commit comments