Skip to content

Commit 99cb393

Browse files
committed
FEAT: Framework for adding tests in at runtime
1 parent 6d5a5cc commit 99cb393

File tree

6 files changed

+26
-2
lines changed

6 files changed

+26
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ endif()
1818

1919
# Directory variables
2020
file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/src/*.cpp)
21+
file(GLOB TEST_FILES ${PROJECT_SOURCE_DIR}/srcTest/*.cpp)
2122
set(MAIN_DIR ${PROJECT_SOURCE_DIR}/src/main)
2223
set(TESTS_DIR ${PROJECT_SOURCE_DIR}/tests)
2324
set(OUT_DIR ${PROJECT_SOURCE_DIR}/src/output)
@@ -34,7 +35,7 @@ elseif(TEST_EXCHANGE)
3435
elseif(TEST_GRADIENT)
3536
add_executable(aether ${SRC_FILES} ${MSIS_FILES} ${MAIN_DIR}/main_test_gradient.cpp)
3637
else()
37-
add_executable(aether ${SRC_FILES} ${MSIS_FILES} ${IE_FILES} ${MAIN_DIR}/main.cpp)
38+
add_executable(aether ${SRC_FILES} ${TEST_FILES} ${MSIS_FILES} ${IE_FILES} ${MAIN_DIR}/main.cpp)
3839
endif()
3940

4041
if(USE_DOUBLE_PRECISION)

include/aether.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,7 @@ using json = nlohmann::json;
143143
// not commented
144144
#include "external_msis.h"
145145

146+
// To hold all the test functions
147+
#include "test.h"
148+
146149
#endif // INCLUDE_AETHER_H_

include/inputs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,12 @@ class Inputs {
562562
\param
563563
**/
564564
std::vector<precision_t> get_satellite_dts();
565+
566+
/**********************************************************************
567+
\brief returns settings["
568+
\param
569+
**/
570+
json get_tests();
565571

566572
// General get_setting functions with error checks:
567573

share/run/UA/inputs/defaults.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,8 @@
130130
"do" : false,
131131
"OutDir" : "UA/restartOut",
132132
"InDir" : "UA/restartIn",
133-
"dt" : 3600.0}
133+
"dt" : 3600.0},
134+
135+
"DoTests": {
136+
"exit_on_fail": true}
134137
}

src/inputs.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,14 @@ bool Inputs::get_advection_neutrals_implicitfriction() {
11631163
return get_setting_bool("Advection", "Neutrals", "useImplicitFriction");
11641164
}
11651165

1166+
// -----------------------------------------------------------------------
1167+
// See what tests are requested
1168+
// -----------------------------------------------------------------------
1169+
1170+
json Inputs::get_tests() {
1171+
return get_setting_json("DoTests");
1172+
}
1173+
11661174
// --------------------------------------------------------------------------
11671175
// check to see if class is ok
11681176
// --------------------------------------------------------------------------

src/main/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ int main() {
3131
report.print(-1, "Hello " +
3232
input.get_student_name() + " - welcome to Aether!");
3333

34+
// Find out what tests we are running:
35+
json tests = input.get_tests();
36+
3437
// For now, the number of processors and blocks are set by the
3538
// neutral grid shape, since this could be sphere (1 root) or
3639
// cubesphere (6 root)

0 commit comments

Comments
 (0)