From 6f7c191513bac7ea0cb95a3b11011e471be777c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Mon, 6 Jul 2020 20:33:08 +0200 Subject: [PATCH] --min-duration is overriden by -d no --- include/reporters/catch_reporter_bases.cpp | 12 ++++++++---- include/reporters/catch_reporter_bases.hpp | 5 +++-- projects/ExtraTests/CMakeLists.txt | 9 +++++++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/reporters/catch_reporter_bases.cpp b/include/reporters/catch_reporter_bases.cpp index 271f90ca..0578e8ab 100644 --- a/include/reporters/catch_reporter_bases.cpp +++ b/include/reporters/catch_reporter_bases.cpp @@ -42,10 +42,14 @@ namespace Catch { } bool shouldShowDuration( IConfig const& config, double duration ) { - if( config.showDurations() == ShowDurations::Always ) - return true; - double min = config.minDuration(); - return min >= 0 && duration >= min; + if ( config.showDurations() == ShowDurations::Always ) { + return true; + } + if ( config.showDurations() == ShowDurations::Never ) { + return false; + } + const double min = config.minDuration(); + return min >= 0 && duration >= min; } std::string serializeFilters( std::vector const& container ) { diff --git a/include/reporters/catch_reporter_bases.hpp b/include/reporters/catch_reporter_bases.hpp index f53794f4..f62e1430 100644 --- a/include/reporters/catch_reporter_bases.hpp +++ b/include/reporters/catch_reporter_bases.hpp @@ -25,7 +25,8 @@ namespace Catch { // Returns double formatted as %.3f (format expected on output) std::string getFormattedDuration( double duration ); - bool shouldShowDuration( IConfig const &, double duration ); + //! Should the reporter show + bool shouldShowDuration( IConfig const& config, double duration ); std::string serializeFilters( std::vector const& container ); @@ -54,7 +55,7 @@ namespace Catch { void noMatchingTestCases(std::string const&) override {} void reportInvalidArguments(std::string const&) override {} - + void testRunStarting(TestRunInfo const& _testRunInfo) override { currentTestRunInfo = _testRunInfo; } diff --git a/projects/ExtraTests/CMakeLists.txt b/projects/ExtraTests/CMakeLists.txt index 63aa678b..e3b8720b 100644 --- a/projects/ExtraTests/CMakeLists.txt +++ b/projects/ExtraTests/CMakeLists.txt @@ -32,6 +32,15 @@ set_tests_properties( PASS_REGULAR_EXPRESSION "s: sleep_for_100ms" ) +# -d no overrides the threshold, so we should never see any tests even +# with ridiculously low min duration threshold +add_test(NAME MinDuration::DurationOverrideNo COMMAND $ --min-duration 0.0001 -d no [min_duration_test]) +set_tests_properties( + MinDuration::DurationOverrideNo + PROPERTIES + FAIL_REGULAR_EXPRESSION "sleep_for_200ms" +) + # ------------ end of duration reporting tests