[ews-build] Parse and display webkitpy failures
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Apr 2019 14:51:13 +0000 (14:51 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Apr 2019 14:51:13 +0000 (14:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197395

Reviewed by Lucas Forschler.

* BuildSlaveSupport/ews-build/steps.py:
(RunWebKitPyTests.start): Initialize log_observer for json output.
(RunWebKitPyTests.getResultSummary): Update step and build summary based on webkitpy results.
(RunWebKitPyTests._addToLog): Method to add message to log.
* BuildSlaveSupport/ews-build/steps_unittest.py: Updated unit-test accordingly.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244769 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/BuildSlaveSupport/ews-build/steps.py
Tools/BuildSlaveSupport/ews-build/steps_unittest.py
Tools/ChangeLog

index e96711e..7b2879b 100644 (file)
@@ -491,6 +491,42 @@ class RunWebKitPyTests(shell.ShellCommand):
     def __init__(self, **kwargs):
         super(RunWebKitPyTests, self).__init__(timeout=2 * 60, **kwargs)
 
+    def start(self):
+        self.log_observer = logobserver.BufferLogObserver()
+        self.addLogObserver('json', self.log_observer)
+        return shell.ShellCommand.start(self)
+
+    def getResultSummary(self):
+        if self.results == SUCCESS:
+            message = 'Passed webkitpy tests'
+            self.build.buildFinished([message], SUCCESS)
+            return {u'step': unicode(message)}
+
+        logLines = self.log_observer.getStdout()
+        json_text = ''.join([line for line in logLines.splitlines()])
+        try:
+            webkitpy_results = json.loads(json_text)
+        except Exception as ex:
+            self._addToLog('stderr', 'ERROR: unable to parse data, exception: {}'.format(ex))
+            return super(RunWebKitPyTests, self).getResultSummary()
+
+        failures = webkitpy_results.get('failures') + webkitpy_results.get('errors')
+        if not failures:
+            return super(RunWebKitPyTests, self).getResultSummary()
+        pluralSuffix = 's' if len(failures) > 1 else ''
+        failures_string = ', '.join([failure.get('name').replace('webkitpy.', '') for failure in failures])
+        message = 'Found {} WebKitPy test failure{}: {}'.format(len(failures), pluralSuffix, failures_string)
+        self.build.buildFinished([message], FAILURE)
+        return {u'step': unicode(message)}
+
+    @defer.inlineCallbacks
+    def _addToLog(self, logName, message):
+        try:
+            log = self.getLog(logName)
+        except KeyError:
+            log = yield self.addLog(logName)
+        log.addStdout(message)
+
 
 def appendCustomBuildFlags(step, platform, fullPlatform):
     # FIXME: Make a common 'supported platforms' list.
index 1f0f03b..c192f24 100644 (file)
@@ -372,7 +372,7 @@ class TestWebKitPyTests(BuildStepMixinAdditions, unittest.TestCase):
                         )
             + 0,
         )
-        self.expectOutcome(result=SUCCESS, state_string='webkitpy-tests')
+        self.expectOutcome(result=SUCCESS, state_string='Passed webkitpy tests')
         return self.runStep()
 
     def test_failure(self):
index bbc4806..439c7be 100644 (file)
@@ -1,3 +1,16 @@
+2019-04-30  Aakash Jain  <aakash_jain@apple.com>
+
+        [ews-build] Parse and display webkitpy failures
+        https://bugs.webkit.org/show_bug.cgi?id=197395
+
+        Reviewed by Lucas Forschler.
+
+        * BuildSlaveSupport/ews-build/steps.py:
+        (RunWebKitPyTests.start): Initialize log_observer for json output.
+        (RunWebKitPyTests.getResultSummary): Update step and build summary based on webkitpy results.
+        (RunWebKitPyTests._addToLog): Method to add message to log.
+        * BuildSlaveSupport/ews-build/steps_unittest.py: Updated unit-test accordingly.
+
 2019-04-29  Alex Christensen  <achristensen@webkit.org>
 
         <rdar://problem/50299396> Fix internal High Sierra build