Tools/ChangeLog

112011-02-18 Dirk Pranke <dpranke@chromium.org>
22
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Fix various bugs related to handling of dir separators and real
 6 vs. fake filesystems that were causing test-webkitpy to fail
 7 tests on win32. These bugs have a variety of causes but are
 8 lumped together because they should be easy to review.
 9
 10 https://bugs.webkit.org/show_bug.cgi?id=54700
 11
 12 * Scripts/webkitpy/common/net/testoutput.py:
 13 Here we were using os.path.sep but not escaping it prior to
 14 using in a regexp, which caused bad things on win32.
 15 * Scripts/webkitpy/common/net/testoutput_unittest.py:
 16 Same here.
 17 * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
 18 Here we were using the native filesystem instead of the mock
 19 filesystem, making some tests unnecessarily platform dependent.
 20 Also we weren't setting the default configuration for the
 21 TestChromiumWinPort.
 22 * Scripts/webkitpy/layout_tests/update_webgl_conformance_tests.py:
 23 Here we *shouldn't* use os.path.join(), just so the code becomes
 24 less platform dependent.
 25 * Scripts/webkitpy/style/checker.py:
 26 Here we should be using os.path.sep instead of "/"; the tests
 27 require the native filesystem.
 28 * Scripts/webkitpy/style/checkers/cpp_unittest.py:
 29 Here the underlying code is using os.path.sep, so we probably
 30 should as well.
 31 * Scripts/webkitpy/style/test_expectations_unittest.py:
 32 Here we should be using the filesystem hanging of the port
 33 object (which is the mocked filesystem) rather than the native
 34 one.
 35
 362011-02-18 Dirk Pranke <dpranke@chromium.org>
 37
338 Reviewed by Ojan Vafai.
439
540 new-run-webkit-tests: enable multiple processes by default on mac

Tools/Scripts/webkitpy/common/net/testoutput.py

@@class TestOutput(object):
4848
4949 def _extract_platform(self, filename):
5050 """Calculates the platform from the name of the file if it isn't known already"""
51  path = re.split(os.path.sep, filename)
 51 path = filename.split(os.path.sep)
5252 if 'platform' in path:
5353 return path[path.index('platform') + 1]
5454 return None
5555
5656 def _extract_test_name(self, filename):
57  path = re.split(os.path.sep, filename)
 57 path = filename.split(os.path.sep)
5858 if 'LayoutTests' in path:
5959 path = path[1 + path.index('LayoutTests'):]
6060 if 'layout-test-results' in path:

Tools/Scripts/webkitpy/common/net/testoutput_unittest.py

2222# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2323# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
 25import os
2526import re
2627import testoutput
2728import unittest

@@class FakeTestOutput(testoutput.TestOutput):
6061
6162class TestOutputTest(unittest.TestCase):
6263 def _check_name(self, filename, expected_test_name):
 64 # FIXME: should consider using MockFileSystem here so as to not
 65 # have to worry about platform-specific path separators.
 66 filename = filename.replace('/', os.path.sep)
 67 expected_test_name = expected_test_name.replace('/', os.path.sep)
6368 r = testoutput.TextTestOutput(None, FakeFile(filename))
6469 self.assertEquals(expected_test_name, r.name())
6570
6671 def _check_platform(self, filename, expected_platform):
 72 # FIXME: should consider using MockFileSystem here so as to not
 73 # have to worry about platform-specific path separators.
 74 filename = filename.replace('/', os.path.sep)
6775 r = testoutput.TextTestOutput(None, FakeFile(filename))
6876 self.assertEquals(expected_platform, r.platform())
6977

Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py

@@class ChromiumPortTest(unittest.TestCase):
9090 class TestMacPort(chromium_mac.ChromiumMacPort):
9191 def __init__(self, options):
9292 chromium_mac.ChromiumMacPort.__init__(self,
93  options=options)
 93 options=options,
 94 filesystem=filesystem_mock.MockFileSystem())
9495
9596 def default_configuration(self):
9697 self.default_configuration_called = True

@@class ChromiumPortTest(unittest.TestCase):
106107 self.default_configuration_called = True
107108 return 'default'
108109
 110 class TestWinPort(chromium_win.ChromiumWinPort):
 111 def __init__(self, options):
 112 chromium_win.ChromiumWinPort.__init__(self,
 113 options=options,
 114 filesystem=filesystem_mock.MockFileSystem())
 115
 116 def default_configuration(self):
 117 self.default_configuration_called = True
 118 return 'default'
 119
109120 def test_path_to_image_diff(self):
110121 mock_options = mocktool.MockOptions()
111122 port = ChromiumPortTest.TestLinuxPort(options=mock_options)
112123 self.assertTrue(port._path_to_image_diff().endswith(
113  '/out/default/ImageDiff'), msg=port._path_to_image_diff())
 124 '/out/default/ImageDiff'))
114125 port = ChromiumPortTest.TestMacPort(options=mock_options)
115126 self.assertTrue(port._path_to_image_diff().endswith(
116127 '/xcodebuild/default/ImageDiff'))
117  # FIXME: Figure out how this is going to work on Windows.
118  #port = chromium_win.ChromiumWinPort('test-port', options=MockOptions())
 128 port = ChromiumPortTest.TestWinPort(options=mock_options)
 129 self.assertTrue(port._path_to_image_diff().endswith(
 130 '/default/ImageDiff.exe'))
119131
120132 def test_skipped_layout_tests(self):
121133 mock_options = mocktool.MockOptions()

Tools/Scripts/webkitpy/layout_tests/update_webgl_conformance_tests.py

@@def translate_includes(text):
5353
5454 for filename, path in include_mapping.items():
5555 search = r'(?:[^"\'= ]*/)?' + re.escape(filename)
56  replace = os.path.join(path, filename)
 56 # We use '/' instead of os.path.join in order to produce consistent
 57 # output cross-platform.
 58 replace = path + '/' + filename
5759 text = re.sub(search, replace, text)
5860
5961 return text

Tools/Scripts/webkitpy/style/checker.py

@@_SKIPPED_FILES_WITH_WARNING = [
253253# This list should be in addition to files with FileType.NONE. Files
254254# with FileType.NONE are automatically skipped without warning.
255255_SKIPPED_FILES_WITHOUT_WARNING = [
256  "LayoutTests/",
 256 "LayoutTests" + os.path.sep,
257257 ]
258258
259259# Extensions of files which are allowed to contain carriage returns.

@@class CheckerDispatcher(object):
475475 elif file_extension in _XML_FILE_EXTENSIONS:
476476 return FileType.XML
477477 elif (os.path.basename(file_path).startswith('ChangeLog') or
478  (not file_extension and "Tools/Scripts/" in file_path) or
 478 (not file_extension and os.path.join("Tools", "Scripts") in file_path) or
479479 file_extension in _TEXT_FILE_EXTENSIONS):
480480 return FileType.TEXT
481481 else:

Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py

@@class CppStyleTest(CppStyleTestBase):
10021002 mock_header_contents = ['']
10031003 message = self.perform_include_what_you_use(
10041004 '''#include "config.h"
1005  #include "%s/a.h"
 1005 #include "%s%sa.h"
10061006
1007  std::set<int> foo;''' % os.path.basename(os.getcwd()),
 1007 std::set<int> foo;''' % (os.path.basename(os.getcwd()), os.path.sep),
10081008 filename='a.cpp',
10091009 io=MockIo(mock_header_contents))
10101010 self.assertEquals(message, 'Add #include <set> for set<> '

Tools/Scripts/webkitpy/style/checkers/test_expectations_unittest.py

@@class TestExpectationsTestCase(unittest.TestCase):
6767 def setUp(self):
6868 self._error_collector = ErrorCollector()
6969 port_obj = port.get('test')
70  self._test_file = os.path.join(port_obj.layout_tests_dir(), 'passes/text.html')
 70 self._test_file = port_obj._filesystem.join(port_obj.layout_tests_dir(), 'passes/text.html')
7171
7272 def process_expectations(self, expectations, overrides=None):
7373 self._checker = TestExpectationsChecker()