From 3afe19965dd6ae2d42df06f57b18a17ca81dbc13 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 27 Jan 2024 04:49:05 -0500 Subject: [PATCH] Describe tests which are skipped. This helps prevent silent test skipping on normal runs. --- Testing/TableTest.test/test.cc | 5 +++++ Testing/test.cc | 15 ++++++++++----- Testing/test.h | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Testing/TableTest.test/test.cc b/Testing/TableTest.test/test.cc index fa1922a..fef4dd0 100644 --- a/Testing/TableTest.test/test.cc +++ b/Testing/TableTest.test/test.cc @@ -27,4 +27,9 @@ namespace { "smoke", { 1 }, 1 }, //{ "fail", { 2 }, 1 }, }; + + auto skippedTest= -"This Test should be skipped."_test <=[] + { + throw 0; + }; } diff --git a/Testing/test.cc b/Testing/test.cc index bf48001..9fe1555 100644 --- a/Testing/test.cc +++ b/Testing/test.cc @@ -26,16 +26,16 @@ namespace Alepha::Hydrogen::Testing::detail::testing std::cerr << "Going to run all tests. (I see " << registry().size() << " tests.)" << std::endl; } bool failed= false; - const auto selected= [ selections ]( const std::string test ) + const auto selected= [selections]( const std::string test ) { for( const auto &selection: selections ) { if( test.find( selection ) != std::string::npos ) return true; } - return empty( selections ); + return selections.empty(); }; - const auto explicitlyNamed= [ selections ]( const std::string s ) + const auto explicitlyNamed= [selections]( const std::string s ) { return std::find( begin( selections ), end( selections ), s ) != end( selections ); }; @@ -44,9 +44,9 @@ namespace Alepha::Hydrogen::Testing::detail::testing { if( C::debugTestRun ) std::cerr << "Trying test " << name << std::endl; + std::cout << C::testStat << "BEGIN" << resetStyle << " : " << name << std::endl; if( explicitlyNamed( name ) or not disabled and selected( name ) ) { - std::cout << C::testStat << "BEGIN" << resetStyle << " : " << name << std::endl; try { test(); @@ -66,8 +66,13 @@ namespace Alepha::Hydrogen::Testing::detail::testing std::cout << std::endl; } - std::cout << C::testStat << "FINISHED" << resetStyle << ": " << name << std::endl; } + else if( disabled ) + { + std::cout << " " << C::testPass << "SUCCESS" << resetStyle << ": " << name << std::endl; + std::cout << " " << C::testInfo << "Note" << resetStyle << ": Test skipped." << std::endl; + } + std::cout << C::testStat << "FINISHED" << resetStyle << ": " << name << std::endl; } return failed ? EXIT_FAILURE : EXIT_SUCCESS; diff --git a/Testing/test.h b/Testing/test.h index a9b7f9e..75f4838 100644 --- a/Testing/test.h +++ b/Testing/test.h @@ -72,9 +72,9 @@ namespace Alepha::Hydrogen::Testing } } - // It is okay to discard this, if making tests in an enroll block. inline namespace impl { + // It is okay to discard this result, if making tests in an enroll block. struct TestRegistration {}; TestRegistration operator <= ( TestName name, std::function< void () > test ); }