catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
--min-duration is overriden by -d no
- Commit
13917c44b423920397dbf026ef8853f847a4656e- Author
- Martin Hořeňovský ·
- Parents
e6d947f6d4f8
Changes
src/catch2/reporters/catch_reporter_bases.cpp | 12 ++++++++---- src/catch2/reporters/catch_reporter_bases.hpp | 3 ++- tests/ExtraTests/CMakeLists.txt | 9 +++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/catch2/reporters/catch_reporter_bases.cpp b/src/catch2/reporters/catch_reporter_bases.cpp index e875b596..09cec4f0 100644 --- a/src/catch2/reporters/catch_reporter_bases.cpp +++ b/src/catch2/reporters/catch_reporter_bases.cpp @@ -44,10 +44,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<std::string> const& container ) { diff --git a/src/catch2/reporters/catch_reporter_bases.hpp b/src/catch2/reporters/catch_reporter_bases.hpp index 7e4457e8..d5f22181 100644 --- a/src/catch2/reporters/catch_reporter_bases.hpp +++ b/src/catch2/reporters/catch_reporter_bases.hpp @@ -24,7 +24,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<std::string> const& container ); diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt index 3c6da4d5..5423ab1f 100644 --- a/tests/ExtraTests/CMakeLists.txt +++ b/tests/ExtraTests/CMakeLists.txt @@ -30,6 +30,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 $<TARGET_FILE:SelfTest> --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