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

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