From 5c9d332c93a9e1253e960d8d5fb38ed777f315fa Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Mon, 21 Oct 2019 23:39:00 +0200 Subject: [PATCH] Improve Catch2 unit tests running Now use separate steps to parse command line options and to run tests This allows to output correctly help messages. `` ./unit_tests -h `` now produces the expected output --- tests/mpi_test_main.cpp | 8 +++++++- tests/test_main.cpp | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/mpi_test_main.cpp b/tests/mpi_test_main.cpp index 541d48a37..ec01b679b 100644 --- a/tests/mpi_test_main.cpp +++ b/tests/mpi_test_main.cpp @@ -15,8 +15,14 @@ main(int argc, char* argv[]) if (parallel::rank() != 0) { setenv("GCOV_PREFIX", "/dev/null", 1); } + Catch::Session session; + int result = session.applyCommandLine(argc, argv); - int result = Catch::Session().run(argc, argv); + if (result == 0) { + // Disable outputs from tested classes to the standard output + std::cout.setstate(std::ios::badbit); + result = session.run(); + } Kokkos::finalize(); parallel::Messenger::destroy(); diff --git a/tests/test_main.cpp b/tests/test_main.cpp index c7355e990..eba6d05d0 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -8,10 +8,14 @@ main(int argc, char* argv[]) { Kokkos::initialize({4, -1, -1, true}); - // Disable outputs from tested classes to the standard output - std::cout.setstate(std::ios::badbit); + Catch::Session session; + int result = session.applyCommandLine(argc, argv); - int result = Catch::Session().run(argc, argv); + if (result == 0) { + // Disable outputs from tested classes to the standard output + std::cout.setstate(std::ios::badbit); + result = session.run(); + } Kokkos::finalize(); -- GitLab