1
0
forked from Alepha/Alepha

Put in some structure to test output.

This helps to visually distinguish between different cases
which executed and when new tests start.
This commit is contained in:
2023-10-24 00:36:04 -04:00
parent 7cd33b9164
commit 794e4404a1
3 changed files with 24 additions and 19 deletions

View File

@ -383,10 +383,10 @@ namespace Alepha::Hydrogen::Testing ::detail:: table_test
const auto result= checker( invoker );
if( not result )
{
std::cout << " " << C::testFail << "FAILED CASE" << resetStyle << ": " << comment << std::endl;
std::cout << " " << C::testFail << "FAILED CASE" << resetStyle << ": " << comment << std::endl;
++failureCount;
}
else std::cout << " " << C::testPass << "PASSED CASE" << resetStyle << ": " << comment << std::endl;
else std::cout << " " << C::testPass << "PASSED CASE" << resetStyle << ": " << comment << std::endl;
}
return failureCount;

View File

@ -12,7 +12,8 @@ namespace Alepha::Hydrogen::Testing ::detail:: testing_colors
{
inline const auto testFail= createStyle( "test-failure", setFgColor( BasicTextColor::red ) );
inline const auto testPass= createStyle( "test-success", setFgColor( BasicTextColor::green ) );
inline const auto testInfo= createStyle( "test-info", "italic ansi:5"_sgr );
inline const auto testWarn= createStyle( "test-warn", "italic ansi:5"_sgr );
inline const auto testInfo= createStyle( "test-info", "ext:rgb235"_sgr );
}
}
}

View File

@ -192,29 +192,33 @@ namespace Alepha::Hydrogen::Testing
};
for( const auto &[ name, disabled, test ]: registry() )
try
{
if( C::debugTestRun ) std::cerr << "Trying test " << name << std::endl;
if( explicitlyNamed( name ) or not disabled and selected( name ) )
{
std::cout << C::testPass << "BEGIN " << resetStyle << ": " << name << std::endl;
test();
std::cout << C::testPass << "SUCCESS" << resetStyle << ": " << name << std::endl;
std::cout << C::testInfo << "BEGIN" << resetStyle << " : " << name << std::endl;
try
{
test();
std::cout << " " << C::testPass << "SUCCESS" << resetStyle << ": " << name << std::endl;
}
catch( ... )
{
try
{
failed= true;
std::cout << " " << C::testFail << "FAILURE" << resetStyle << ": " << name;
throw;
}
catch( const TestFailureException &fail ) { std::cout << " -- " << fail.failureCount << " failures."; }
catch( ... ) { std::cout << " -- unknown failure count"; }
std::cout << std::endl;
}
std::cout << C::testInfo << "FINISHED" << resetStyle << ": " << name << std::endl;
}
}
catch( ... )
{
try
{
failed= true;
std::cout << C::testFail << "FAILURE" << resetStyle << ": " << name;
throw;
}
catch( const TestFailureException &fail ) { std::cout << " -- " << fail.failureCount << " failures."; }
catch( ... ) { std::cout << " -- unknown failure count"; }
std::cout << std::endl;
}
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
}