1
0
forked from Alepha/Alepha

Describe tests which are skipped.

This helps prevent silent test skipping on normal runs.
This commit is contained in:
2024-01-27 04:49:05 -05:00
parent 08654a9a86
commit 3afe19965d
3 changed files with 16 additions and 6 deletions

View File

@ -27,4 +27,9 @@ namespace
{ "smoke", { 1 }, 1 },
//{ "fail", { 2 }, 1 },
};
auto skippedTest= -"This Test should be skipped."_test <=[]
{
throw 0;
};
}

View File

@ -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;

View File

@ -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 );
}