diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7e8db00bf..cab2030fe 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,7 +10,7 @@ target_include_directories(Catch2 INTERFACE ${CMAKE_CURRENT_LIST_DIR}) add_library(Catch2::Catch2 ALIAS Catch2) include(Catch) -set(CATCH_EXTRA_ARGS "--durations yes" CACHE STRING "Extra arguments for catch2 test suites.") +set(CATCH_EXTRA_ARGS "-r usefulconsole" CACHE STRING "Extra arguments for catch2 test suites.") add_library(test_common INTERFACE) target_compile_definitions(test_common INTERFACE TEST_DATA_DIR=R"\(${TEST_DATA_DIR}\)" CATCH_CONFIG_FAST_COMPILE) diff --git a/tests/catch_main.hpp b/tests/catch_main.hpp new file mode 100644 index 000000000..e49ff40b4 --- /dev/null +++ b/tests/catch_main.hpp @@ -0,0 +1,51 @@ +#ifndef CATCH_MAIN +#define CATCH_MAIN + +#define CATCH_CONFIG_EXTERNAL_INTERFACES +#define CATCH_CONFIG_MAIN +#include + +namespace Catch { +struct VerboseConsoleReporter : public ConsoleReporter { + double duration = 0.; + using ConsoleReporter::ConsoleReporter; + + void testCaseStarting(TestCaseInfo const& _testInfo) override + { + Colour::use(Colour::Cyan); + stream << "Testing "; + Colour::use(Colour::None); + stream << _testInfo.name << std::endl; + ConsoleReporter::testCaseStarting(_testInfo); + } + + void sectionStarting(const SectionInfo &_sectionInfo) override + { + if (_sectionInfo.name != currentTestCaseInfo->name) + stream << _sectionInfo.name << std::endl; + + ConsoleReporter::sectionStarting(_sectionInfo); + } + + void sectionEnded(const SectionStats &_sectionStats) override { + duration += _sectionStats.durationInSeconds; + ConsoleReporter::sectionEnded(_sectionStats); + } + + void testCaseEnded(TestCaseStats const& stats) override + { + if (stats.totals.assertions.allOk()) { + Colour::use(Colour::BrightGreen); + stream << "Passed"; + Colour::use(Colour::None); + stream << " in " << duration << " [seconds]\n" << std::endl; + } + + duration = 0.; + ConsoleReporter::testCaseEnded(stats); + } +}; +CATCH_REGISTER_REPORTER( "verboseconsole", VerboseConsoleReporter ) +} + +#endif // CATCH_MAIN diff --git a/tests/example/example_tests_main.cpp b/tests/example/example_tests_main.cpp index d612f323c..32e8d02b7 100644 --- a/tests/example/example_tests_main.cpp +++ b/tests/example/example_tests_main.cpp @@ -1,5 +1,5 @@ #define CATCH_CONFIG_MAIN -#include +#include TEST_CASE("Is example succesful", "[example]") { REQUIRE(true); diff --git a/tests/fff_print/fff_print_tests.cpp b/tests/fff_print/fff_print_tests.cpp index 5e9b82f80..46358e5eb 100644 --- a/tests/fff_print/fff_print_tests.cpp +++ b/tests/fff_print/fff_print_tests.cpp @@ -1,4 +1,3 @@ -#define CATCH_CONFIG_MAIN -#include +#include #include "libslic3r/libslic3r.h" diff --git a/tests/libnest2d/libnest2d_tests_main.cpp b/tests/libnest2d/libnest2d_tests_main.cpp index 252bea47f..c7259ae53 100644 --- a/tests/libnest2d/libnest2d_tests_main.cpp +++ b/tests/libnest2d/libnest2d_tests_main.cpp @@ -1,9 +1,7 @@ -#define CATCH_CONFIG_MAIN -#include +#include #include - #include #include "printer_parts.hpp" //#include diff --git a/tests/libslic3r/libslic3r_tests.cpp b/tests/libslic3r/libslic3r_tests.cpp index 907304f57..caf5b3b9a 100644 --- a/tests/libslic3r/libslic3r_tests.cpp +++ b/tests/libslic3r/libslic3r_tests.cpp @@ -1,5 +1,4 @@ -#define CATCH_CONFIG_MAIN -#include +#include #include "libslic3r/libslic3r.h" diff --git a/tests/sla_print/sla_print_tests.cpp b/tests/sla_print/sla_print_tests.cpp index f41fd3200..229eb4267 100644 --- a/tests/sla_print/sla_print_tests.cpp +++ b/tests/sla_print/sla_print_tests.cpp @@ -1,5 +1,4 @@ -#define CATCH_CONFIG_MAIN -#include +#include #include #include diff --git a/tests/timeutils/timeutils_tests_main.cpp b/tests/timeutils/timeutils_tests_main.cpp index c3827374e..9989f9871 100644 --- a/tests/timeutils/timeutils_tests_main.cpp +++ b/tests/timeutils/timeutils_tests_main.cpp @@ -1,5 +1,4 @@ -#define CATCH_CONFIG_MAIN -#include +#include #include "libslic3r/Time.hpp"