rework new failed test reporting

Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/34b14da2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/34b14da2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/34b14da2

Branch: refs/heads/master
Commit: 34b14da2a96d43b6b25308d6a3ab279fcb14c05e
Parents: 5908f90
Author: Dale LaBossiere <[email protected]>
Authored: Wed Sep 28 15:20:56 2016 -0400
Committer: Dale LaBossiere <[email protected]>
Committed: Wed Sep 28 15:20:56 2016 -0400

----------------------------------------------------------------------
 build.gradle | 41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/34b14da2/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index 362e05c..7e4d15f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -419,7 +419,25 @@ subprojects {
     }
   }
   
+  ext.printFile = { path ->
+    ant.concat { fileset(file: path) }
+  }
   ext.adjustTest7Classpath = false
+  
+  task testSummaryFinalizer << {
+    def testTask = tasks.getByName('test')
+    if (System.properties['edgent.build.ci'] != null) {
+      testTask.failedTestResultPaths.each { path ->
+        println path
+        printFile path
+      }
+    }
+    def result = testTask.summaryResult
+    if (result != null) {
+      def duration = String.format('%.3fsec', (result.endTime - 
result.startTime) / 1000)
+      println "$project.path $duration $result.resultType ($result.testCount 
tests, $result.failedTestCount failures, $result.skippedTestCount skipped)"
+    }
+  }
 
   test {
     filter {
@@ -439,32 +457,21 @@ subprojects {
     }
     ext.failedTestResultPaths = []
     ext.summaryResult = null
-    ext.printFile = { path ->
-      ant.concat { fileset(file: path) }
-    }
     afterSuite { desc, result ->
+      // make failures in edgent.build.ci runs more debuggable
+      // wish the junit xml files existed at this moment but they don't
       if (desc.parent && desc.className != null) {  // individual test class 
result
-        def resultFile = "$testResultsDir/test/TEST-${desc.className}.xml"
-        println "Testrun results: $resultFile"
         if (result.resultType == TestResult.ResultType.FAILURE) {
+          def resultFile = "$testResultsDir/test/TEST-${desc.className}.xml"
+          println "\nFailed testrun results: $resultFile"
           failedTestResultPaths.add resultFile
         }
       }
-      else { // project's overall results
+      else if (!desc.parent) { // project's overall results
         summaryResult = result 
       }
     }
-    doLast {
-      if (System.properties['edgent.build.ci'] != null) {
-        failedTestResultPaths.each { path ->
-          println path
-          printFile path
-        }
-      }
-      def result = summaryResult
-      def duration = String.format('%.3fsec', (result.endTime - 
result.startTime) / 1000)
-      println "$project.path $duration $result.resultType ($result.testCount 
tests, $result.failedTestCount failures, $result.skippedTestCount skipped)"
-    }
+    finalizedBy "testSummaryFinalizer" // a doLast isn't invoked if there's a 
test failure
     reports {
       junitXml.enabled = true  // generate build/test-results/test/TEST-*.xml
       // individual <project>/build/reports junit/jacoco html reports not 
needed with aggregate report

Reply via email to