Skip to content

Commit

Permalink
Switch to com.adarshr:gradle-test-logger-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Feb 29, 2024
1 parent b22df6b commit 804db3c
Showing 1 changed file with 3 additions and 72 deletions.
75 changes: 3 additions & 72 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,82 +1,12 @@
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
classpath("org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.3")
}
}

// source: https://github.com/mendhak/Gradle-Travis-Colored-Output/blob/master/ColoredOutput.gradle
tasks.withType(Test).configureEach {

String ANSI_BOLD_WHITE = "\u001B[0;1m";
String ANSI_RESET = "\u001B[0m";
String ANSI_BLACK = "\u001B[30m";
String ANSI_RED = "\u001B[31m";
String ANSI_GREEN = "\u001B[32m";
String ANSI_YELLOW = "\u001B[33m";
String ANSI_BLUE = "\u001B[34m";
String ANSI_PURPLE = "\u001B[35m";
String ANSI_CYAN = "\u001B[36m";
String ANSI_WHITE = "\u001B[37m";
String CHECK_MARK = "\u2713";
String NEUTRAL_FACE = "\u0CA0_\u0CA0";
String X_MARK = "\u274C";
String indent = '\t';

def outputCache = new HashMap<TestDescriptor, List<String>>()

beforeTest { TestDescriptor descriptor -> outputCache.put(descriptor, new ArrayList()) }

onOutput { TestDescriptor descriptor, TestOutputEvent testOutputEvent ->

def outputLines = outputCache.get(descriptor)
if (outputLines != null) {
outputLines.add(testOutputEvent.getMessage())
}
}

afterTest { TestDescriptor descriptor, TestResult result ->
if (result.failedTestCount > 0) {
String output = outputCache.remove(descriptor).join(indent)


def nameParts = descriptor.parent.name.split("\\.")
def simpleParentName = nameParts[nameParts.length - 1]

out.println()
out.println(simpleParentName + " > " + descriptor.name + " STANDARD_OUT")
out.println(indent + output)
out.println()
}
}

afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def failStyle = ANSI_RED
def skipStyle = ANSI_YELLOW
def summaryStyle = ANSI_WHITE

switch (result.resultType) {
case TestResult.ResultType.SUCCESS:
summaryStyle = ANSI_GREEN;
break;
case TestResult.ResultType.FAILURE:
summaryStyle = ANSI_RED;
break;
}

out.println("--------------------------------------------------------------------------");
out.println("Results: " + summaryStyle + " ${result.resultType} " + ANSI_RESET
+ " (${result.testCount} tests, "
+ ANSI_GREEN + " ${result.successfulTestCount} passed " + ANSI_RESET
+ ", " + failStyle + " ${result.failedTestCount} failed " + ANSI_RESET
+ ", " + skipStyle + " ${result.skippedTestCount} skipped " + ANSI_RESET
+ ")");
out.println("--------------------------------------------------------------------------");
}
classpath("com.adarshr:gradle-test-logger-plugin:4.0.0")
}
}

Expand All @@ -85,6 +15,7 @@ subprojects {
apply plugin: 'maven-publish'
apply plugin: 'java-library'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'com.adarshr.test-logger'

group = 'com.faforever.commons'
version = '1.0-SNAPSHOT'
Expand Down

0 comments on commit 804db3c

Please sign in to comment.