Build: Fix test logger NPE when no tests are run (#28929)

This commit fixes the test progress logging to not produce an NPE when
there are no tests run. The onQuit method is always called, but onStart
would not be called if no tests match the test patterns.
This commit is contained in:
Ryan Ernst 2018-03-07 15:51:49 -08:00 committed by GitHub
parent 9d4f09db68
commit ea5b6c4fc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -100,12 +100,15 @@ class TestProgressLogger implements AggregatedEventListener {
@Subscribe
void onQuit(AggregatedQuitEvent e) throws IOException {
suiteLogger.completed()
testLogger.completed()
for (ProgressLogger slaveLogger : slaveLoggers) {
slaveLogger.completed()
// if onStart was never called (eg no matching tests), suiteLogger and all the other loggers will be null
if (suiteLogger != null) {
suiteLogger.completed()
testLogger.completed()
for (ProgressLogger slaveLogger : slaveLoggers) {
slaveLogger.completed()
}
parentProgressLogger.completed()
}
parentProgressLogger.completed()
}
@Subscribe