Diff
Modified: trunk/Tools/ChangeLog (213305 => 213306)
--- trunk/Tools/ChangeLog 2017-03-02 22:38:07 UTC (rev 213305)
+++ trunk/Tools/ChangeLog 2017-03-02 22:46:01 UTC (rev 213306)
@@ -1,3 +1,33 @@
+2017-03-02 Srinivasan Vijayaraghavan <svijayaragha...@apple.com>
+
+ Refactor test results classes in webkitpy to enable faster EWS iteration
+ https://bugs.webkit.org/show_bug.cgi?id=169053
+
+ Reviewed by Alexey Proskuryakov.
+
+ * Scripts/webkitpy/common/net/abstracttestresults.py:
+ (AbstractTestResults): Import json for parse_json_string().
+ (AbstractTestResults.parse_json_string): Abstracted out from JSCTestResults.results_from_string().
+ * Scripts/webkitpy/common/net/abstracttestresults_unittest.py: Added.
+ (AbstractTestResultsTest): Class that tests AbstractTestResults.
+ (AbstractTestResultsTest.test_parse_json_string_invalid_inputs): Move unit tests from JSCTestResultsTest.
+ (AbstractTestResultsTest.test_parse_json_string_valid_input): Add a unit test for a success case.
+ * Scripts/webkitpy/common/net/jsctestresults.py:
+ (JSCTestResults.results_from_string): Call parse_json_string because it was abstracted out.
+ * Scripts/webkitpy/common/net/jsctestresults_unittest.py:
+ (JSCTestResultsTest.test_results_from_string): Remove JSON parsing unit tests, because they were moved.
+ * Scripts/webkitpy/tool/bot/abstracttestresultsreader.py: Added.
+ (AbstractTestResultsReader): Generic TestResultsReader with functions common to jsc, bindings etc.
+ (AbstractTestResultsReader.__init__): Moved from JSCTestResultsReader.__init__().
+ (AbstractTestResultsReader._read_file_contents): Moved from JSCTestResultsReader._read_file_contents().
+ (AbstractTestResultsReader.results): Stub.
+ * Scripts/webkitpy/tool/bot/jsctestresultsreader.py:
+ (JSCTestResultsReader): Now inherits from AbstractTestResultsReader.
+ (JSCTestResultsReader.__init__): Deleted.
+ (JSCTestResultsReader._read_file_contents): Deleted.
+ * Scripts/webkitpy/tool/bot/layouttestresultsreader.py:
+ (LayoutTestResultsReader): Now inherits from AbstractTestResultsReader.
+
2017-03-02 Alex Christensen <achristen...@webkit.org>
Continue enabling WebRTC
Modified: trunk/Tools/Scripts/webkitpy/common/net/abstracttestresults.py (213305 => 213306)
--- trunk/Tools/Scripts/webkitpy/common/net/abstracttestresults.py 2017-03-02 22:38:07 UTC (rev 213305)
+++ trunk/Tools/Scripts/webkitpy/common/net/abstracttestresults.py 2017-03-02 22:46:01 UTC (rev 213306)
@@ -20,6 +20,7 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import json
import logging
_log = logging.getLogger(__name__)
@@ -26,6 +27,17 @@
class AbstractTestResults(object):
+ @classmethod
+ def parse_json_string(cls, string):
+ if not string:
+ return None
+
+ try:
+ return json.loads(string)
+ except ValueError:
+ _log.error('Invalid JSON results')
+ return None
+
def failing_tests(self):
raise NotImplementedError("subclasses must implement")
Copied: trunk/Tools/Scripts/webkitpy/common/net/abstracttestresults_unittest.py (from rev 213305, trunk/Tools/Scripts/webkitpy/tool/bot/jsctestresultsreader.py) (0 => 213306)
--- trunk/Tools/Scripts/webkitpy/common/net/abstracttestresults_unittest.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/net/abstracttestresults_unittest.py 2017-03-02 22:46:01 UTC (rev 213306)
@@ -0,0 +1,43 @@
+# Copyright (C) 2017 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import unittest
+
+from webkitpy.common.net.abstracttestresults import AbstractTestResults
+
+
+class AbstractTestResultsTest(unittest.TestCase):
+ def test_parse_json_string_invalid_inputs(self):
+ none_item = None
+ empty_json = ''
+ invalid_json = '{"allApiTestsPassed":'
+ invalid_json_v2 = '{"err'
+ self.assertEqual(None, AbstractTestResults.parse_json_string(none_item))
+ self.assertEqual(None, AbstractTestResults.parse_json_string(empty_json))
+ self.assertEqual(None, AbstractTestResults.parse_json_string(invalid_json))
+ self.assertEqual(None, AbstractTestResults.parse_json_string(invalid_json_v2))
+
+ def test_parse_json_string_valid_input(self):
+ test_string = '{"failures": ["fail1", "fail2"], "errors": []}'
+ test_dict = {"failures": ["fail1", "fail2"], "errors": []}
+
+ self.assertEqual(test_dict, AbstractTestResults.parse_json_string(test_string))
Modified: trunk/Tools/Scripts/webkitpy/common/net/jsctestresults.py (213305 => 213306)
--- trunk/Tools/Scripts/webkitpy/common/net/jsctestresults.py 2017-03-02 22:38:07 UTC (rev 213305)
+++ trunk/Tools/Scripts/webkitpy/common/net/jsctestresults.py 2017-03-02 22:46:01 UTC (rev 213306)
@@ -20,7 +20,6 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import json
import logging
from webkitpy.common.net.abstracttestresults import AbstractTestResults
@@ -45,15 +44,10 @@
@classmethod
def results_from_string(cls, string):
- if not string:
+ parsed_results = cls.parse_json_string(string)
+ if not parsed_results:
return None
- try:
- parsed_results = json.loads(string)
- except ValueError:
- _log.error('Invalid JSON results')
- return None
-
if 'allApiTestsPassed' not in parsed_results or 'stressTestFailures' not in parsed_results:
return None
Modified: trunk/Tools/Scripts/webkitpy/common/net/jsctestresults_unittest.py (213305 => 213306)
--- trunk/Tools/Scripts/webkitpy/common/net/jsctestresults_unittest.py 2017-03-02 22:38:07 UTC (rev 213305)
+++ trunk/Tools/Scripts/webkitpy/common/net/jsctestresults_unittest.py 2017-03-02 22:46:01 UTC (rev 213306)
@@ -27,14 +27,8 @@
class JSCTestResultsTest(unittest.TestCase):
def test_results_from_string(self):
- none_item = None
- empty_json = ''
- invalid_json = '{"allApiTestsPassed":'
incomplete_json_v1 = '{"allApiTestsPassed": true}'
incomplete_json_v2 = '{"stressTestFailures":[]}'
- self.assertEqual(None, JSCTestResults.results_from_string(none_item))
- self.assertEqual(None, JSCTestResults.results_from_string(empty_json))
- self.assertEqual(None, JSCTestResults.results_from_string(invalid_json))
self.assertEqual(None, JSCTestResults.results_from_string(incomplete_json_v1))
self.assertEqual(None, JSCTestResults.results_from_string(incomplete_json_v2))
Copied: trunk/Tools/Scripts/webkitpy/tool/bot/abstracttestresultsreader.py (from rev 213305, trunk/Tools/Scripts/webkitpy/tool/bot/jsctestresultsreader.py) (0 => 213306)
--- trunk/Tools/Scripts/webkitpy/tool/bot/abstracttestresultsreader.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/tool/bot/abstracttestresultsreader.py 2017-03-02 22:46:01 UTC (rev 213306)
@@ -0,0 +1,41 @@
+# Copyright (C) 2017 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import logging
+
+_log = logging.getLogger(__name__)
+
+
+class AbstractTestResultsReader(object):
+ def __init__(self, host, results_directory):
+ self._host = host
+ self._results_directory = results_directory
+
+ def _read_file_contents(self, path):
+ try:
+ return self._host.filesystem.read_text_file(path)
+ except (IOError, KeyError):
+ _log.error('File could not be read: %s' % path)
+ return None
+
+ def results(self):
+ raise NotImplementedError("subclasses must implement")
Modified: trunk/Tools/Scripts/webkitpy/tool/bot/jsctestresultsreader.py (213305 => 213306)
--- trunk/Tools/Scripts/webkitpy/tool/bot/jsctestresultsreader.py 2017-03-02 22:38:07 UTC (rev 213305)
+++ trunk/Tools/Scripts/webkitpy/tool/bot/jsctestresultsreader.py 2017-03-02 22:46:01 UTC (rev 213306)
@@ -23,21 +23,12 @@
import logging
from webkitpy.common.net.jsctestresults import JSCTestResults
+from webkitpy.tool.bot.abstracttestresultsreader import AbstractTestResultsReader
_log = logging.getLogger(__name__)
-class JSCTestResultsReader(object):
- def __init__(self, host, results_directory):
- self._host = host
- self._results_directory = results_directory
-
- def _read_file_contents(self, path):
- try:
- return self._host.filesystem.read_text_file(path)
- except (IOError, KeyError):
- return None
-
+class JSCTestResultsReader(AbstractTestResultsReader):
def results(self):
results_path = self._host.filesystem.join(self._results_directory, 'jsc_test_results.json')
contents = self._read_file_contents(results_path)
Modified: trunk/Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader.py (213305 => 213306)
--- trunk/Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader.py 2017-03-02 22:38:07 UTC (rev 213305)
+++ trunk/Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader.py 2017-03-02 22:46:01 UTC (rev 213306)
@@ -30,6 +30,7 @@
from webkitpy.common.net.layouttestresults import LayoutTestResults
from webkitpy.common.net.unittestresults import UnitTestResults
+from webkitpy.tool.bot.abstracttestresultsreader import AbstractTestResultsReader
from webkitpy.tool.steps.runtests import RunTests
_log = logging.getLogger(__name__)
@@ -37,7 +38,7 @@
# FIXME: This class no longer has a clear purpose, and should probably
# be made part of Port, or renamed to LayoutTestResultsArchiver or something more fitting?
-class LayoutTestResultsReader(object):
+class LayoutTestResultsReader(AbstractTestResultsReader):
def __init__(self, host, results_directory, archive_directory):
self._host = host
self._results_directory = results_directory