Skip to content

Commit

Permalink
Merge pull request #44257 from Qrox/newline
Browse files Browse the repository at this point in the history
Fix unit test terminating message not starting on new line
  • Loading branch information
ZhilkinSerg authored Sep 19, 2020
2 parents facb03d + 636ef81 commit 987bd4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build-scripts/problem-matchers/json.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"owner": "cata-json",
"pattern": [
{
"regexp": "^(?:Terminated: )?Json error: ([^:]*):([0-9]+):([0-9]+): (.*)$",
"regexp": "^Json error: ([^:]*):([0-9]+):([0-9]+): (.*)$",
"file": 1,
"line": 2,
"column": 3,
Expand Down
23 changes: 11 additions & 12 deletions tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,16 @@ int main( int argc, const char *argv[] )

// If the run is terminated due to a crash during initialization, we won't
// see the seed unless it's printed out in advance, so do that here.
printf( "Randomness seeded to: %u\n", seed );
DebugLog( D_INFO, DC_ALL ) << "Randomness seeded to: " << seed;
}

try {
// TODO: Only init game if we're running tests that need it.
init_global_game_state( mods, option_overrides_for_test_suite, user_dir );
} catch( const std::exception &err ) {
fprintf( stderr, "Terminated: %s\n", err.what() );
fprintf( stderr,
"Make sure that you're in the correct working directory and your data isn't corrupted.\n" );
DebugLog( D_ERROR, DC_ALL ) << "Terminated:\n" << err.what();
DebugLog( D_INFO, DC_ALL ) <<
"Make sure that you're in the correct working directory and your data isn't corrupted.";
return EXIT_FAILURE;
}

Expand All @@ -324,7 +324,7 @@ int main( int argc, const char *argv[] )
std::time_t start_time = std::chrono::system_clock::to_time_t( start );
// Leading newline in case there were debug messages during
// initialization.
printf( "\nStarting the actual test at %s", std::ctime( &start_time ) );
DebugLog( D_INFO, DC_ALL ) << "Starting the actual test at " << std::ctime( &start_time );
result = session.run();
const auto end = std::chrono::system_clock::now();
std::time_t end_time = std::chrono::system_clock::to_time_t( end );
Expand All @@ -333,22 +333,21 @@ int main( int argc, const char *argv[] )
if( result == 0 || dont_save ) {
world_generator->delete_world( world_name, true );
} else {
printf( "Test world \"%s\" left for inspection.\n", world_name.c_str() );
DebugLog( D_INFO, DC_ALL ) << "Test world " << world_name << " left for inspection.";
}

std::chrono::duration<double> elapsed_seconds = end - start;
printf( "Ended test at %sThe test took %.3f seconds\n", std::ctime( &end_time ),
elapsed_seconds.count() );
DebugLog( D_INFO, DC_ALL ) << "Ended test at " << std::ctime( &end_time );
DebugLog( D_INFO, DC_ALL ) << "The test took " << elapsed_seconds.count() << " seconds";

if( error_during_initialization ) {
printf( "\nTreating result as failure due to error logged during initialization.\n" );
printf( "Randomness seeded to: %u\n", seed );
DebugLog( D_INFO, DC_ALL ) <<
"Treating result as failure due to error logged during initialization.";
return 1;
}

if( debug_has_error_been_observed() ) {
printf( "\nTreating result as failure due to error logged during tests.\n" );
printf( "Randomness seeded to: %u\n", seed );
DebugLog( D_INFO, DC_ALL ) << "Treating result as failure due to error logged during tests.";
return 1;
}

Expand Down

0 comments on commit 987bd4b

Please sign in to comment.