From 69cb852a9cec1ab78046942e5d0a6373a62d45fb Mon Sep 17 00:00:00 2001 From: Michael Muller Date: Thu, 22 Aug 2019 11:10:56 -0400 Subject: [PATCH] Add a "showErrorOutput" property (#237) * Add a "showErrorOutput" property Add a property to let us dump test output and final status in real-time to the console. --- build.gradle | 32 ++++++++++++++++++++++++++++++++ gradle.properties | 1 + 2 files changed, 33 insertions(+) diff --git a/build.gradle b/build.gradle index beafc10c3..61c986ea7 100644 --- a/build.gradle +++ b/build.gradle @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.gradle.api.tasks.testing.logging.TestLogEvent + buildscript { if (rootProject.enableDependencyLocking.toBoolean()) { // Lock buildscript dependencies. @@ -256,6 +259,35 @@ subprojects { } } +// If "-P verboseTestOutput=true" is passed in, configure all subprojects to dump all of their +// output and final test status (pass/fail, errors) for each test class. +// +// Note that we can't do this in the main subprojects section above because that's evaluated before +// the subproject build files and the test tasks haven't been defined yet. We have to do it from +// the projectsEvaluted hook, which gets called after the subprojects are configured. +if (verboseTestOutput.toBoolean()) { + gradle.projectsEvaluated({ + subprojects { + tasks.withType(Test) { + testLogging { + events TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED, + TestLogEvent.STANDARD_OUT, TestLogEvent.STANDARD_ERROR + exceptionFormat TestExceptionFormat.FULL + showExceptions true + showCauses true + showStackTraces true + + afterSuite { desc, result -> + println "Results: ${result.resultType}, " + + "${result.successfulTestCount}/${result.testCount} tests " + + "passed, ${result.failedTestCount} failures."; + } + } + } + } + }) +} + task checkDependenciesDotGradle { def buildSrcDepsFile = File.createTempFile('buildSrc', 'deps') buildSrcDepsFile.deleteOnExit() diff --git a/gradle.properties b/gradle.properties index 52523fc8f..2df3cf760 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,5 +3,6 @@ pluginsUrl= uploaderDestination= uploaderCredentialsFile= uploaderMultithreadedUpload= +verboseTestOutput=false flowDocsFile= enableDependencyLocking=true