From 8f6f1b3b7f2032b4d16f956c8e62b0f2b58345d7 Mon Sep 17 00:00:00 2001 From: Benjamin Boyle Date: Fri, 7 May 2021 01:09:42 -0700 Subject: [PATCH 1/2] Consolidate test logging Move test logging to consolidated block. Change all 'rootProject' to 'project'. --- build.gradle | 69 ++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/build.gradle b/build.gradle index 329e8347fe..5ec53c35e9 100644 --- a/build.gradle +++ b/build.gradle @@ -71,7 +71,7 @@ javadoc { options.addStringOption("top").value = "" options.addStringOption("doctitle").value = "" options.addStringOption("header").value = "" - options.stylesheetFile = rootProject.file("gradle/stylesheet.css") + options.stylesheetFile = project.file("gradle/stylesheet.css") options.links( "https://docs.oracle.com/javase/8/docs/api/", @@ -99,7 +99,7 @@ jar { } license { - header rootProject.file("config/license/HEADER") + header project.file("config/license/HEADER") ext.year = Calendar.getInstance().get(Calendar.YEAR) skipExistingHeaders true ignoreFailures true @@ -120,51 +120,36 @@ jmh { } test { - testLogging { - // showing skipped occasionally should prevent CI timeout due to lack of standard output - events=["skipped", "failed"] // "started", "passed" - // showStandardStreams = true - exceptionFormat="full" - - debug.events = ["skipped", "failed"] - debug.exceptionFormat="full" - - info.events = ["failed", "skipped"] - info.exceptionFormat="full" - - warn.events = ["failed", "skipped"] - warn.exceptionFormat="full" - } - maxHeapSize = "1200m" - - if (System.getenv("CI") == null) { - maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 - } } -task testng(type: Test) { +task testNG(type: Test) { useTestNG() - testLogging { - events=["skipped", "failed"] - exceptionFormat="full" +} + +check.dependsOn testNG + +tasks.withType(Test) { + testLogging { + events = ["skipped", "failed"] + exceptionFormat = "full" debug.events = ["skipped", "failed"] - debug.exceptionFormat="full" + debug.exceptionFormat = "full" info.events = ["failed", "skipped"] - info.exceptionFormat="full" - + info.exceptionFormat = "full" + warn.events = ["failed", "skipped"] - warn.exceptionFormat="full" - } -} + warn.exceptionFormat = "full" + } -check.dependsOn testng + maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 +} jacocoTestReport { dependsOn test - dependsOn testng + dependsOn testNG reports { xml.enabled = true @@ -175,18 +160,18 @@ jacocoTestReport { check.dependsOn jacocoTestReport checkstyle { - configFile = rootProject.file("config/checkstyle/checkstyle.xml") + configFile = project.file("config/checkstyle/checkstyle.xml") configProperties = [ - "checkstyle.suppressions.file": rootProject.file("config/checkstyle/suppressions.xml"), - "checkstyle.header.file": rootProject.file("config/license/HEADER_JAVA") + "checkstyle.suppressions.file": project.file("config/checkstyle/suppressions.xml"), + "checkstyle.header.file": project.file("config/license/HEADER_JAVA") ] } -if (rootProject.hasProperty("releaseMode")) { - logger.lifecycle("ReleaseMode: {}", rootProject.releaseMode) +if (project.hasProperty("releaseMode")) { + logger.lifecycle("ReleaseMode: {}", project.releaseMode) + + if ("branch" == project.releaseMode) { - if ("branch".equals(rootProject.releaseMode)) { - if (version.endsWith("-SNAPSHOT")) { publishing { repositories { @@ -204,7 +189,7 @@ if (rootProject.hasProperty("releaseMode")) { } } - if ("full".equals(rootProject.releaseMode)) { + if ("full" == project.releaseMode) { signing { if (project.hasProperty("SIGNING_PRIVATE_KEY") && project.hasProperty("SIGNING_PASSWORD")) { useInMemoryPgpKeys(project.getProperty("SIGNING_PRIVATE_KEY"), project.getProperty("SIGNING_PASSWORD")) From f34f33217f490b54b368f19c3617246d20448aba Mon Sep 17 00:00:00 2001 From: Benjamin Boyle Date: Fri, 7 May 2021 02:24:58 -0700 Subject: [PATCH 2/2] Only do parallel testing on non-CI machines --- build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 5ec53c35e9..535aefc268 100644 --- a/build.gradle +++ b/build.gradle @@ -144,7 +144,9 @@ tasks.withType(Test) { warn.exceptionFormat = "full" } - maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 + if (System.getenv("CI") == null) { + maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1 + } } jacocoTestReport {