Skip to content

Commit

Permalink
Remove leftover build files and simplify ProgressLogger usage
Browse files Browse the repository at this point in the history
These files should have been removed in an earlier commit. This commit also simplifies usage of ProgressLoggerWrapper by using the Groovy delegation instead of using explicit delegation.
  • Loading branch information
ywelsch committed Jan 24, 2017
1 parent 5103b76 commit e37a7d7
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 81 deletions.
26 changes: 0 additions & 26 deletions buildSrc/src/compile/groovy/gradle-2.13-loggers.groovy

This file was deleted.

26 changes: 0 additions & 26 deletions buildSrc/src/compile/groovy/gradle-2.14-loggers.groovy

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@
*/
package org.elasticsearch.gradle

import org.gradle.logging.ProgressLogger

/**
* Wraps a ProgressLogger so that code in src/main/groovy does not need to
* define imports on Gradle 2.13/2.14+ ProgressLoggers
*/
class ProgressLoggerWrapper {
ProgressLogger progressLogger
class ProgressLogger {
@Delegate org.gradle.logging.ProgressLogger progressLogger

ProgressLoggerWrapper(ProgressLogger progressLogger) {
ProgressLogger(org.gradle.logging.ProgressLogger progressLogger) {
this.progressLogger = progressLogger
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@
*/
package org.elasticsearch.gradle

import org.gradle.internal.logging.progress.ProgressLogger

/**
* Wraps a ProgressLogger so that code in src/main/groovy does not need to
* define imports on Gradle 2.13/2.14+ ProgressLoggers
*/
class ProgressLoggerWrapper {
ProgressLogger progressLogger
class ProgressLogger {
@Delegate org.gradle.internal.logging.progress.ProgressLogger progressLogger

ProgressLoggerWrapper(ProgressLogger progressLogger) {
ProgressLogger(org.gradle.internal.logging.progress.ProgressLogger progressLogger) {
this.progressLogger = progressLogger
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedStartEvent
import com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedSuiteResultEvent
import com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedTestResultEvent
import com.carrotsearch.ant.tasks.junit4.listeners.AggregatedEventListener
import org.elasticsearch.gradle.ProgressLoggerWrapper
import org.elasticsearch.gradle.ProgressLogger

import static com.carrotsearch.ant.tasks.junit4.FormattingUtils.formatDurationInSeconds
import static com.carrotsearch.ant.tasks.junit4.events.aggregated.TestStatus.ERROR
Expand All @@ -51,7 +51,7 @@ import static java.lang.Math.max
* quick.
*/
class TestProgressLogger implements AggregatedEventListener {
ProgressLoggerWrapper progressLoggerWrapper
ProgressLogger progressLogger
int totalSuites
int totalSlaves

Expand All @@ -77,16 +77,16 @@ class TestProgressLogger implements AggregatedEventListener {
lets us move things around without worying about breaking things. */

TestProgressLogger(Map args) {
progressLoggerWrapper = new ProgressLoggerWrapper(args.factory.newOperation(TestProgressLogger))
progressLoggerWrapper.progressLogger.setDescription('Randomized test runner')
progressLogger = new ProgressLogger(args.factory.newOperation(TestProgressLogger))
progressLogger.setDescription('Randomized test runner')
}

@Subscribe
void onStart(AggregatedStartEvent e) throws IOException {
totalSuites = e.suiteCount
totalSlaves = e.slaveCount
progressLoggerWrapper.progressLogger.started()
progressLoggerWrapper.progressLogger.progress(
progressLogger.started()
progressLogger.progress(
"Starting JUnit4 for ${totalSuites} suites on ${totalSlaves} jvms")

suitesFormat = "%0${widthForTotal(totalSuites)}d"
Expand Down Expand Up @@ -178,7 +178,7 @@ class TestProgressLogger implements AggregatedEventListener {
log += "J${sprintf(slavesFormat, eventSlave)} "
}
log += "completed ${eventDescription}"
progressLoggerWrapper.progressLogger.progress(log)
progressLogger.progress(log)
}

private static int widthForTotal(int total) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package org.elasticsearch.gradle.vagrant

import com.carrotsearch.gradle.junit4.LoggingOutputStream
import groovy.transform.PackageScope
import org.elasticsearch.gradle.ProgressLoggerWrapper
import org.elasticsearch.gradle.ProgressLogger
import org.gradle.api.GradleScriptException
import org.gradle.api.logging.Logger

Expand All @@ -37,7 +37,7 @@ import java.util.regex.Matcher
* entire TAP stream at once and won't parse it stream-wise.
*/
public class TapLoggerOutputStream extends LoggingOutputStream {
private final ProgressLoggerWrapper progressLoggerWrapper
private final ProgressLogger progressLogger
private boolean isStarted = false
private final Logger logger
private int testsCompleted = 0
Expand All @@ -48,14 +48,14 @@ public class TapLoggerOutputStream extends LoggingOutputStream {

TapLoggerOutputStream(Map args) {
logger = args.logger
progressLoggerWrapper = new ProgressLoggerWrapper(args.factory.newOperation(VagrantLoggerOutputStream))
progressLoggerWrapper.progressLogger.setDescription("TAP output for `${args.command}`")
progressLogger = new ProgressLogger(args.factory.newOperation(VagrantLoggerOutputStream))
progressLogger.setDescription("TAP output for `${args.command}`")
}

@Override
public void flush() {
if (isStarted == false) {
progressLoggerWrapper.progressLogger.started()
progressLogger.started()
isStarted = true
}
if (end == start) return
Expand Down Expand Up @@ -104,7 +104,7 @@ public class TapLoggerOutputStream extends LoggingOutputStream {

String counts = sprintf(countsFormat,
[testsCompleted, testsFailed, testsSkipped, testCount])
progressLoggerWrapper.progressLogger.progress("Tests $counts, $status [$suiteName] $testName")
progressLogger.progress("Tests $counts, $status [$suiteName] $testName")
if (!success) {
logger.warn(line)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.elasticsearch.gradle.vagrant

import com.carrotsearch.gradle.junit4.LoggingOutputStream
import org.elasticsearch.gradle.ProgressLoggerWrapper
import org.elasticsearch.gradle.ProgressLogger

/**
* Adapts an OutputStream being written to by vagrant into a ProcessLogger. It
Expand All @@ -45,23 +45,23 @@ import org.elasticsearch.gradle.ProgressLoggerWrapper
public class VagrantLoggerOutputStream extends LoggingOutputStream {
private static final String HEADING_PREFIX = '==> '

private final ProgressLoggerWrapper progressLoggerWrapper
private final ProgressLogger progressLogger
private boolean isStarted = false
private String squashedPrefix
private String lastLine = ''
private boolean inProgressReport = false
private String heading = ''

VagrantLoggerOutputStream(Map args) {
progressLoggerWrapper = new ProgressLoggerWrapper(args.factory.newOperation(VagrantLoggerOutputStream))
progressLoggerWrapper.progressLogger.setDescription("Vagrant output for `$args.command`")
progressLogger = new ProgressLogger(args.factory.newOperation(VagrantLoggerOutputStream))
progressLogger.setDescription("Vagrant output for `$args.command`")
squashedPrefix = args.squashedPrefix
}

@Override
public void flush() {
if (isStarted == false) {
progressLoggerWrapper.progressLogger.started()
progressLogger.started()
isStarted = true
}
if (end == start) return
Expand Down Expand Up @@ -96,6 +96,6 @@ public class VagrantLoggerOutputStream extends LoggingOutputStream {
} else {
return
}
progressLoggerWrapper.progressLogger.progress(line)
progressLogger.progress(line)
}
}

0 comments on commit e37a7d7

Please sign in to comment.