forked from NOAA-OWP/ngen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
291 lines (257 loc) · 8.09 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
project(test)
add_subdirectory(googletest)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
include_directories(${PROJ_ROOT_INCLUDE_DIR})
if (NGEN_ACTIVATE_PYTHON)
include_directories(${PROJECT_SOURCE_DIR}/extern/pybind11/include)
add_compile_definitions(NGEN_BMI_PY_TESTS_ACTIVE)
endif()
if(MPI_ACTIVE)
add_compile_definitions(NGEN_MPI_TESTS_ACTIVE)
endif()
if(BMI_C_LIB_ACTIVE)
add_compile_definitions(NGEN_BMI_C_LIB_TESTS_ACTIVE)
endif()
if(BMI_FORTRAN_ACTIVE)
add_compile_definitions(NGEN_BMI_FORTRAN_LIB_TESTS_ACTIVE)
endif()
if(LSTM_TORCH_LIB_ACTIVE)
add_compile_definitions(LSTM_TORCH_LIB_TESTS_ACTIVE)
endif()
if(NGEN_ACTIVATE_ROUTING)
add_compile_definitions(ROUTING_PYBIND_TESTS_ACTIVE)
endif()
# Add test source files (e.g., test1.cpp)
#add_executable(test_hymod models/hymod/include/HymodTest.cpp)
#target_link_libraries(test_hymod gtest gtest_main)
function(add_test TESTNAME NUM_FILES)
math(EXPR NUM_LINKS "${ARGC} - ${NUM_FILES}")
list(SUBLIST ARGN 0 ${NUM_FILES} SOURCE_FILES)
list(SUBLIST ARGN ${NUM_FILES} ${NUM_LINKS} LINKED_LIBS)
# Also link these testing libraries for anything
# TODO: verify these do not remove current value at i = 0, but instead push it forward
list(INSERT LINKED_LIBS 0 gtest gtest_main)
# Sanity check for duplicates
list(REMOVE_DUPLICATES LINKED_LIBS)
# Create the testing executable target and link the libraries
add_executable(${TESTNAME} ${SOURCE_FILES})
target_link_libraries(${TESTNAME} ${LINKED_LIBS})
# Perform the final GoogleTest boilerplate steps
gtest_discover_tests(${TESTNAME}
WORKING_DIRECTORY ${PROJECT_DIR}
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_DIR}"
)
set_target_properties(${TESTNAME} PROPERTIES FOLDER test)
endfunction()
########################## Individual tests ##########################
#add_automated_test(test_hymod models/hymod/include/HymodTest.cpp)
#
#add_automated_test(
# test_tshirt
# models/tshirt/include/TshirtTest.cpp
# realizations/catchments/Tshirt_C_Realization_Test.cpp
#)
########################## GeoJSON Unit Tests
add_test(test_geojson
4
geojson/JSONProperty_Test.cpp
geojson/JSONGeometry_Test.cpp
geojson/Feature_Test.cpp
geojson/FeatureCollection_Test.cpp
NGen::geojson
)
########################## Realization Config Unit Tests
add_test(test_realization_config
1
realizations/Formulation_Manager_Test.cpp
NGen::core
NGen::realizations_catchment
NGen::core_mediator
libudunits2
)
########################## GIUH Unit Tests
add_test(
test_giuh
1
core/catchment/giuh/GIUH_Test.cpp
NGen::core_catchment_giuh
)
########################## Nexus Tests
add_test(
test_nexus
1
core/nexus/NexusTests.cpp
NGen::core_nexus
)
########################## MPI Remote Nexus Tests
if(MPI_ACTIVE)
add_test(
test_remote_nexus
1
core/nexus/NexusRemoteTests.cpp
NGen::core_nexus
)
endif()
########################## Partitioning Tests
if(MPI_ACTIVE)
#TODO this test depends on a "reference hydrofabric" that is rather large
#and the path to that reference is absolute in the test code. Need to rethink this.
add_test(
test_partition
1
utils/Partition_Test.cpp
NGen::core
NGen::geojson
)
endif()
########################## BMI C Tests
if(BMI_C_LIB_ACTIVE)
add_test(
test_bmi_c
2
realizations/catchments/Bmi_C_Adapter_Test.cpp
realizations/catchments/Bmi_C_Formulation_Test.cpp
NGen::core
NGen::realizations_catchment
NGen::core_mediator
libudunits2
)
endif()
########################## BMI Fortran Tests
if (${BMI_FORTRAN_ACTIVE})
add_test(
test_bmi_fortran
2
realizations/catchments/Bmi_Fortran_Adapter_Test.cpp
realizations/catchments/Bmi_Fortran_Formulation_Test.cpp
NGen::core
NGen::realizations_catchment
NGen::core_mediator
libudunits2
)
endif()
########################## BMI Python Tests
if (${NGEN_ACTIVATE_PYTHON})
add_test(
test_bmi_python
2
realizations/catchments/Bmi_Py_Adapter_Test.cpp
realizations/catchments/Bmi_Py_Formulation_Test.cpp
NGen::core
NGen::realizations_catchment
NGen::core_mediator
libudunits2
)
endif()
########################## BMI Multi Tests
add_test(
test_bmi_multi
1
realizations/catchments/Bmi_Multi_Formulation_Test.cpp
NGen::core
NGen::realizations_catchment
NGen::core_mediator
libudunits2
)
########################## Comparison tests for the BMI CFE implementation
# TODO: this probably needs to be added to integration testing also
add_test(
compare_cfe
1
realizations/catchments/Bmi_C_Cfe_IT.cpp
NGen::core
NGen::realizations_catchment
NGen::core_mediator
libudunits2
)
########################## Internal Torchlib LSTM Tests
if(LSTM_TORCH_LIB_ACTIVE)
add_test(
test_lstm
2
models/lstm/include/LSTM_Test.cpp
realizations/catchments/LSTM_Realization_Test.cpp
NGen::core
NGen::realizations_catchment
NGen::core_mediator
libudunits2
)
endif()
########################## Routing Tests
if(NGEN_ACTIVATE_ROUTING)
add_test(
test_routing_pybind
1
routing/Routing_Py_Bind_Test.cpp
NGen::routing
pybind11::embed
)
endif()
########################## Network Class Tests
add_test(
test_network
1
core/NetworkTests.cpp
NGen::core
NGen::geojson
)
########################## Primary Combined Unit Test Target
add_test(
test_unit
17
models/hymod/include/HymodTest.cpp
models/hymod/include/Reservoir_Test.cpp
models/hymod/include/Reservoir_Timeless_Test.cpp
models/tshirt/include/TshirtTest.cpp
realizations/catchments/Tshirt_C_Realization_Test.cpp
geojson/JSONProperty_Test.cpp
geojson/JSONGeometry_Test.cpp
geojson/Feature_Test.cpp
geojson/FeatureCollection_Test.cpp
forcing/Forcing_Test.cpp
forcing/CsvPerFeatureForcingProvider_Test.cpp
core/mediator/UnitsHelper_Tests.cpp
simulation_time/Simulation_Time_Test.cpp
core/catchment/giuh/GIUH_Test.cpp
core/NetworkTests.cpp
utils/include/StreamOutputTest.cpp
realizations/Formulation_Manager_Test.cpp
NGen::core
NGen::core_nexus
NGen::core_mediator
NGen::geojson
NGen::realizations_catchment
libudunits2
)
# Add for integration tests once we have some
#add_automated_test(test_it models/hymod/include/HymodTest.cpp)
# All automated tests
add_test(
test_all
16
models/hymod/include/HymodTest.cpp
models/hymod/include/Reservoir_Test.cpp
models/hymod/include/Reservoir_Timeless_Test.cpp
models/tshirt/include/TshirtTest.cpp
realizations/catchments/Tshirt_C_Realization_Test.cpp
geojson/JSONProperty_Test.cpp
geojson/JSONGeometry_Test.cpp
geojson/Feature_Test.cpp
geojson/FeatureCollection_Test.cpp
forcing/Forcing_Test.cpp
forcing/CsvPerFeatureForcingProvider_Test.cpp
simulation_time/Simulation_Time_Test.cpp
core/catchment/giuh/GIUH_Test.cpp
core/mediator/UnitsHelper_Tests.cpp
realizations/Formulation_Manager_Test.cpp
core/nexus/NexusTests.cpp
# TODO: this probably should be added, but at the moment it's broken (update number-of-files arg above also)
#utils/Partition_Test.cpp
NGen::core
gmock
NGen::core_nexus
NGen::core_mediator
NGen::geojson
NGen::realizations_catchment
libudunits2
)