Skip to content

Commit

Permalink
Attempt 1: make sure to always flush buffered logs
Browse files Browse the repository at this point in the history
Previously, buffered logs would sometimes not get flushed resulting in
lost test report output. See scalameta#408. This commit adds an extra attempt to
flush the buffered logs inside the sbt testing framework in case the
logs don't get flushed by the JUnit test listener. I'm not 100% sure
this fixes the problem but it seems worth a short and it shouldn't cause
a regression.
  • Loading branch information
olafurpg committed Aug 31, 2021
1 parent 9cfd8b1 commit 18b3e9f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ public void testRunFinished(Result result)
", " +
result.getIgnoreCount()+" ignored" +
", "+result.getRunCount()+" total, "+(result.getRunTime()/1000.0)+"s") ;
logger.flush();
}
runStatistics.addTime(result.getRunTime());
}
Expand All @@ -174,7 +173,6 @@ public void testRunStarted(Description desc)
{
if (settings.verbose) {
logger.info(taskInfo + " started");
logger.flush();
}
}

Expand All @@ -183,7 +181,6 @@ void testExecutionFailed(String testName, Throwable err)
post(new Event(Ansi.c(testName, Ansi.ERRMSG), settings.buildErrorMessage(err), Status.Error, 0L, err) {
void logTo(RichLogger logger) {
logger.error(ansiName+" failed: "+ansiMsg, error);
logger.flush();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public Task[] execute(EventHandler eventHandler, Logger[] loggers) {
ed.testExecutionFailed(testClassName, ex);
}
} finally {
logger.flush();
settings.restoreSystemProperties(oldprops);
}
return new Task[0]; // junit tests do not nest
Expand Down

0 comments on commit 18b3e9f

Please sign in to comment.