2011-01-19 Dirk Pranke <dpranke@chromium.org>
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jan 2011 04:17:09 +0000 (04:17 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jan 2011 04:17:09 +0000 (04:17 +0000)
        Unreviewed, build fix - I pulled this patch in to fix an issue
        revealed by r76195 running on some new bots). Also fix a couple
        of other issues revealed in testing.

        nrwt: remove fs refs from layout_package/json*

        https://bugs.webkit.org/show_bug.cgi?id=52754

        * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py:
        * Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py:
        * Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py:
        * Scripts/webkitpy/layout_tests/layout_package/test_runner.py:
        * Scripts/webkitpy/layout_tests/port/base.py:

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

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py
Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py
Tools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py
Tools/Scripts/webkitpy/layout_tests/layout_package/test_runner.py
Tools/Scripts/webkitpy/layout_tests/port/base.py

index 4ff749e6e56a115a1cc439c48a446958c30090ab..0492c4da3ea13575cd8f82cc8333bdad252be800 100644 (file)
@@ -1,3 +1,19 @@
+2011-01-19  Dirk Pranke  <dpranke@chromium.org>
+
+        Unreviewed, build fix - I pulled this patch in to fix an issue
+        revealed by r76195 running on some new bots). Also fix a couple
+        of other issues revealed in testing.
+
+        nrwt: remove fs refs from layout_package/json*
+
+        https://bugs.webkit.org/show_bug.cgi?id=52754
+
+        * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py:
+        * Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py:
+        * Scripts/webkitpy/layout_tests/layout_package/json_results_generator_unittest.py:
+        * Scripts/webkitpy/layout_tests/layout_package/test_runner.py:
+        * Scripts/webkitpy/layout_tests/port/base.py:
+
 2011-01-19  Dirk Pranke  <dpranke@chromium.org>
 
         Unreviewed, build fix.
index b054c5b23054ff9f0c8efc94ad14baccb1db4cbf..3267fb7ddc536ad71eb6aa058a131050652f9b49 100644 (file)
@@ -27,7 +27,6 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import logging
-import os
 
 from webkitpy.layout_tests.layout_package import json_results_generator
 from webkitpy.layout_tests.layout_package import test_expectations
@@ -66,12 +65,11 @@ class JSONLayoutResultsGenerator(json_results_generator.JSONResultsGeneratorBase
               results.
         """
         super(JSONLayoutResultsGenerator, self).__init__(
-            builder_name, build_name, build_number, results_file_base_path,
+            port, builder_name, build_name, build_number, results_file_base_path,
             builder_base_url, {}, port.test_repository_paths(),
             generate_incremental_results, test_results_server,
             test_type, master_name)
 
-        self._port = port
         self._expectations = expectations
 
         # We want relative paths to LayoutTest root for JSON output.
@@ -181,9 +179,9 @@ class JSONLayoutResultsGenerator(json_results_generator.JSONResultsGeneratorBase
             test, test_name, tests)
 
         # Remove tests that don't exist anymore.
-        full_path = os.path.join(self._port.layout_tests_dir(), test_name)
-        full_path = os.path.normpath(full_path)
-        if not os.path.exists(full_path):
+        full_path = self._fs.join(self._port.layout_tests_dir(), test_name)
+        full_path = self._fs.normpath(full_path)
+        if not self._fs.exists(full_path):
             del tests[test_name]
 
     def _get_failure_summary_entry(self, timeline):
index 12e65b2f9dfc39cd29b24543a6331e2473d41068..32ffd71fe70e62b72ff57f2fc1535ecbf235d9a7 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-from __future__ import with_statement
-
-import codecs
 import logging
-import os
 import subprocess
 import sys
 import time
@@ -118,7 +114,7 @@ class JSONResultsGeneratorBase(object):
     URL_FOR_TEST_LIST_JSON = \
         "http://%s/testfile?builder=%s&name=%s&testlistjson=1&testtype=%s"
 
-    def __init__(self, builder_name, build_name, build_number,
+    def __init__(self, port, builder_name, build_name, build_number,
         results_file_base_path, builder_base_url,
         test_results_map, svn_repositories=None,
         generate_incremental_results=False,
@@ -129,6 +125,7 @@ class JSONResultsGeneratorBase(object):
         if it is not found locally.
 
         Args
+          port: port-specific wrapper
           builder_name: the builder name (e.g. Webkit).
           build_name: the build name (e.g. webkit-rel).
           build_number: the build number.
@@ -146,14 +143,16 @@ class JSONResultsGeneratorBase(object):
           test_type: test type string (e.g. 'layout-tests').
           master_name: the name of the buildbot master.
         """
+        self._port = port
+        self._fs = port._filesystem
         self._builder_name = builder_name
         self._build_name = build_name
         self._build_number = build_number
         self._builder_base_url = builder_base_url
         self._results_directory = results_file_base_path
-        self._results_file_path = os.path.join(results_file_base_path,
+        self._results_file_path = self._fs.join(results_file_base_path,
             self.RESULTS_FILENAME)
-        self._incremental_results_file_path = os.path.join(
+        self._incremental_results_file_path = self._fs.join(
             results_file_base_path, self.INCREMENTAL_RESULTS_FILENAME)
 
         self._test_results_map = test_results_map
@@ -254,7 +253,7 @@ class JSONResultsGeneratorBase(object):
                  ("testtype", self._test_type),
                  ("master", self._master_name)]
 
-        files = [(file, os.path.join(self._results_directory, file))
+        files = [(file, self._fs.join(self._results_directory, file))
             for file in json_files]
 
         uploader = test_results_uploader.TestResultsUploader(
@@ -273,10 +272,7 @@ class JSONResultsGeneratorBase(object):
         # Specify separators in order to get compact encoding.
         json_data = simplejson.dumps(json, separators=(',', ':'))
         json_string = self.JSON_PREFIX + json_data + self.JSON_SUFFIX
-
-        results_file = codecs.open(file_path, "w", "utf-8")
-        results_file.write(json_string)
-        results_file.close()
+        self._fs.write_text_file(file_path, json_string)
 
     def _get_test_timing(self, test_name):
         """Returns test timing data (elapsed time) in second
@@ -330,7 +326,7 @@ class JSONResultsGeneratorBase(object):
         Args:
           in_directory: The directory where svn is to be run.
         """
-        if os.path.exists(os.path.join(in_directory, '.svn')):
+        if self._fs.exists(self._fs.join(in_directory, '.svn')):
             # Note: Not thread safe: http://bugs.python.org/issue2320
             output = subprocess.Popen(["svn", "info", "--xml"],
                                       cwd=in_directory,
@@ -358,9 +354,8 @@ class JSONResultsGeneratorBase(object):
         old_results = None
         error = None
 
-        if os.path.exists(self._results_file_path) and not for_incremental:
-            with codecs.open(self._results_file_path, "r", "utf-8") as file:
-                old_results = file.read()
+        if self._fs.exists(self._results_file_path) and not for_incremental:
+            old_results = self._fs.read_text_file(self._results_file_path)
         elif self._builder_base_url or for_incremental:
             if for_incremental:
                 if not self._test_results_server:
index dad549acaf76d87ec5f50ccc2570841f66ffabb0..ce997658fb4160bb859892f554e3a9a4e00932ce 100644 (file)
 import unittest
 import optparse
 import random
-import shutil
-import tempfile
 
+from webkitpy.common.system import filesystem_mock
 from webkitpy.layout_tests.layout_package import json_results_generator
 from webkitpy.layout_tests.layout_package import test_expectations
+from webkitpy.thirdparty.mock import Mock
 
 
 class JSONGeneratorTest(unittest.TestCase):
@@ -83,7 +83,9 @@ class JSONGeneratorTest(unittest.TestCase):
                 failed=(test in failed_tests),
                 elapsed_time=test_timings[test])
 
-        generator = json_results_generator.JSONResultsGeneratorBase(
+        port = Mock()
+        port._filesystem = filesystem_mock.MockFileSystem()
+        generator = json_results_generator.JSONResultsGeneratorBase(port,
             self.builder_name, self.build_name, self.build_number,
             '',
             None,   # don't fetch past json results archive
index 67524d35a76af31645fb66e075bde9d74ffc8b5a..6bdbda978926d8d9a054ab4dc2e0bfb7a2c45a6b 100644 (file)
@@ -35,6 +35,8 @@ objects to the TestRunner.  The TestRunner then aggregates the TestFailures to
 create a final report.
 """
 
+from __future__ import with_statement
+
 import errno
 import logging
 import math
index 74c10184c9d726ef713856cbe7a0fb51f3359a34..6e5fabc0d4f364a3d5a37b2fc8e1eea01bc472ef 100644 (file)
@@ -117,7 +117,10 @@ class Port(object):
 
         self._pretty_patch_path = self.path_from_webkit_base("Websites",
             "bugs.webkit.org", "PrettyPatch", "prettify.rb")
-        self._pretty_patch_available = True
+        # If we're running on a mocked-out filesystem, this file almost
+        # certainly won't be available, so it's a good test to keep us
+        # from erroring out later.
+        self._pretty_patch_available = self._filesystem.exists(self._pretty_patch_path)
         self.set_option_default('configuration', None)
         if self._options.configuration is None:
             self._options.configuration = self.default_configuration()