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

@ -12,7 +12,8 @@ namespace Alepha::Hydrogen::Testing ::detail:: testing_colors
{ {
inline const auto testFail= createStyle( "test-failure", setFgColor( BasicTextColor::red ) ); inline const auto testFail= createStyle( "test-failure", setFgColor( BasicTextColor::red ) );
inline const auto testPass= createStyle( "test-success", setFgColor( BasicTextColor::green ) ); 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,23 +192,23 @@ namespace Alepha::Hydrogen::Testing
}; };
for( const auto &[ name, disabled, test ]: registry() ) for( const auto &[ name, disabled, test ]: registry() )
try
{ {
if( C::debugTestRun ) std::cerr << "Trying test " << name << std::endl; if( C::debugTestRun ) std::cerr << "Trying test " << name << std::endl;
if( explicitlyNamed( name ) or not disabled and selected( name ) ) if( explicitlyNamed( name ) or not disabled and selected( name ) )
{ {
std::cout << C::testPass << "BEGIN " << resetStyle << ": " << name << std::endl; std::cout << C::testInfo << "BEGIN" << resetStyle << " : " << name << std::endl;
try
{
test(); test();
std::cout << C::testPass << "SUCCESS" << resetStyle << ": " << name << std::endl; std::cout << " " << C::testPass << "SUCCESS" << resetStyle << ": " << name << std::endl;
}
} }
catch( ... ) catch( ... )
{ {
try try
{ {
failed= true; failed= true;
std::cout << C::testFail << "FAILURE" << resetStyle << ": " << name; std::cout << " " << C::testFail << "FAILURE" << resetStyle << ": " << name;
throw; throw;
} }
catch( const TestFailureException &fail ) { std::cout << " -- " << fail.failureCount << " failures."; } catch( const TestFailureException &fail ) { std::cout << " -- " << fail.failureCount << " failures."; }
@ -216,6 +216,10 @@ namespace Alepha::Hydrogen::Testing
std::cout << std::endl; std::cout << std::endl;
} }
std::cout << C::testInfo << "FINISHED" << resetStyle << ": " << name << std::endl;
}
}
return failed ? EXIT_FAILURE : EXIT_SUCCESS; return failed ? EXIT_FAILURE : EXIT_SUCCESS;
} }