Skip to content

Commit cf2d7f7

Browse files
authored
Build: Fix test logger NPE when no tests are run (elastic#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.
1 parent 363a632 commit cf2d7f7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

buildSrc/src/main/groovy/com/carrotsearch/gradle/junit4/TestProgressLogger.groovy

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,15 @@ class TestProgressLogger implements AggregatedEventListener {
100100

101101
@Subscribe
102102
void onQuit(AggregatedQuitEvent e) throws IOException {
103-
suiteLogger.completed()
104-
testLogger.completed()
105-
for (ProgressLogger slaveLogger : slaveLoggers) {
106-
slaveLogger.completed()
103+
// if onStart was never called (eg no matching tests), suiteLogger and all the other loggers will be null
104+
if (suiteLogger != null) {
105+
suiteLogger.completed()
106+
testLogger.completed()
107+
for (ProgressLogger slaveLogger : slaveLoggers) {
108+
slaveLogger.completed()
109+
}
110+
parentProgressLogger.completed()
107111
}
108-
parentProgressLogger.completed()
109112
}
110113

111114
@Subscribe

0 commit comments

Comments
 (0)