From 1c1de357247c2db38bb45a86977e8b05a977e644 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Thu, 25 Jun 2020 12:44:05 +0200 Subject: [PATCH] [App] Abort if no tests for reference solutions. Abort if test definitions exist but no tests were actually constructed from the configuration. --- Applications/ApplicationsLib/TestDefinition.cpp | 5 +++++ Applications/ApplicationsLib/TestDefinition.h | 1 + Applications/CLI/ogs.cpp | 9 ++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Applications/ApplicationsLib/TestDefinition.cpp b/Applications/ApplicationsLib/TestDefinition.cpp index 2ea84a43347..4641fadb68e 100644 --- a/Applications/ApplicationsLib/TestDefinition.cpp +++ b/Applications/ApplicationsLib/TestDefinition.cpp @@ -287,4 +287,9 @@ std::vector<std::string> const& TestDefinition::getOutputFiles() const { return _output_files; } + +std::size_t TestDefinition::numberOfTests() const +{ + return size(_command_lines); +} } // namespace ApplicationsLib diff --git a/Applications/ApplicationsLib/TestDefinition.h b/Applications/ApplicationsLib/TestDefinition.h index a562544e192..668f7a9bf39 100644 --- a/Applications/ApplicationsLib/TestDefinition.h +++ b/Applications/ApplicationsLib/TestDefinition.h @@ -34,6 +34,7 @@ public: bool runTests() const; std::vector<std::string> const& getOutputFiles() const; + std::size_t numberOfTests() const; private: std::vector<std::string> _command_lines; diff --git a/Applications/CLI/ogs.cpp b/Applications/CLI/ogs.cpp index 5d8fff6658a..1f499d35371 100644 --- a/Applications/CLI/ogs.cpp +++ b/Applications/CLI/ogs.cpp @@ -68,7 +68,8 @@ int main(int argc, char* argv[]) TCLAP::ValueArg<std::string> reference_path_arg( "r", "reference", "Run output result comparison after successful simulation comparing to " - "all files in the given path.", + "all files in the given path. This requires test definitions to be " + "present in the project file.", false, "", "PATH"); cmd.add(reference_path_arg); @@ -204,6 +205,12 @@ int main(int argc, char* argv[]) project_config->getConfigSubtree("test_definition"), reference_path_arg.getValue(), outdir_arg.getValue()); + if( test_definition->numberOfTests() == 0) + { + OGS_FATAL( + "No tests were constructed from the test definitions, " + "but reference solutions path was given."); + } INFO("Cleanup possible output files before running ogs."); BaseLib::removeFiles(test_definition->getOutputFiles()); -- GitLab