| Index: Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py
|
| diff --git a/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py b/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py
|
| index fb84fe1f3f1843c98bb6b37f15e948f977a4c066..e75350034b1bb281bf65387278de4b0c0df47645 100644
|
| --- a/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py
|
| +++ b/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py
|
| @@ -45,7 +45,9 @@ from webkitpy.layout_tests.port import Port, Driver, DriverOutput
|
| from webkitpy.layout_tests.port.base import VirtualTestSuite
|
| from webkitpy.layout_tests.port.test import add_unit_tests_to_mock_filesystem, TestPort
|
|
|
| +
|
| class PortTest(unittest.TestCase):
|
| +
|
| def make_port(self, executive=None, with_tests=False, port_name=None, **kwargs):
|
| host = MockSystemHost()
|
| if executive:
|
| @@ -60,27 +62,27 @@ class PortTest(unittest.TestCase):
|
| self.assertIsNotNone(port.default_child_processes())
|
|
|
| def test_format_wdiff_output_as_html(self):
|
| - output = "OUTPUT %s %s %s" % (Port._WDIFF_DEL, Port._WDIFF_ADD, Port._WDIFF_END)
|
| + output = 'OUTPUT %s %s %s' % (Port._WDIFF_DEL, Port._WDIFF_ADD, Port._WDIFF_END)
|
| html = self.make_port()._format_wdiff_output_as_html(output)
|
| - expected_html = "<head><style>.del { background: #faa; } .add { background: #afa; }</style></head><pre>OUTPUT <span class=del> <span class=add> </span></pre>"
|
| + expected_html = '<head><style>.del { background: #faa; } .add { background: #afa; }</style></head><pre>OUTPUT <span class=del> <span class=add> </span></pre>'
|
| self.assertEqual(html, expected_html)
|
|
|
| def test_wdiff_command(self):
|
| port = self.make_port()
|
| - port._path_to_wdiff = lambda: "/path/to/wdiff"
|
| - command = port._wdiff_command("/actual/path", "/expected/path")
|
| + port._path_to_wdiff = lambda: '/path/to/wdiff'
|
| + command = port._wdiff_command('/actual/path', '/expected/path')
|
| expected_command = [
|
| - "/path/to/wdiff",
|
| - "--start-delete=##WDIFF_DEL##",
|
| - "--end-delete=##WDIFF_END##",
|
| - "--start-insert=##WDIFF_ADD##",
|
| - "--end-insert=##WDIFF_END##",
|
| - "/actual/path",
|
| - "/expected/path",
|
| + '/path/to/wdiff',
|
| + '--start-delete=##WDIFF_DEL##',
|
| + '--end-delete=##WDIFF_END##',
|
| + '--start-insert=##WDIFF_ADD##',
|
| + '--end-insert=##WDIFF_END##',
|
| + '/actual/path',
|
| + '/expected/path',
|
| ]
|
| self.assertEqual(command, expected_command)
|
|
|
| - def _file_with_contents(self, contents, encoding="utf-8"):
|
| + def _file_with_contents(self, contents, encoding='utf-8'):
|
| new_file = tempfile.NamedTemporaryFile()
|
| new_file.write(contents.encode(encoding))
|
| new_file.flush()
|
| @@ -90,11 +92,11 @@ class PortTest(unittest.TestCase):
|
| port = self.make_port(executive=executive_mock.MockExecutive2(exception=OSError))
|
| oc = OutputCapture()
|
| oc.capture_output()
|
| - self.assertEqual(port.pretty_patch_text("patch.txt"),
|
| + self.assertEqual(port.pretty_patch_text('patch.txt'),
|
| port._pretty_patch_error_html)
|
|
|
| # This tests repeated calls to make sure we cache the result.
|
| - self.assertEqual(port.pretty_patch_text("patch.txt"),
|
| + self.assertEqual(port.pretty_patch_text('patch.txt'),
|
| port._pretty_patch_error_html)
|
| oc.restore_output()
|
|
|
| @@ -102,11 +104,11 @@ class PortTest(unittest.TestCase):
|
| # FIXME: This is some ugly white-box test hacking ...
|
| port = self.make_port(executive=executive_mock.MockExecutive2(exception=ScriptError))
|
| port._pretty_patch_available = True
|
| - self.assertEqual(port.pretty_patch_text("patch.txt"),
|
| + self.assertEqual(port.pretty_patch_text('patch.txt'),
|
| port._pretty_patch_error_html)
|
|
|
| # This tests repeated calls to make sure we cache the result.
|
| - self.assertEqual(port.pretty_patch_text("patch.txt"),
|
| + self.assertEqual(port.pretty_patch_text('patch.txt'),
|
| port._pretty_patch_error_html)
|
|
|
| def test_wdiff_text(self):
|
| @@ -143,9 +145,9 @@ class PortTest(unittest.TestCase):
|
| self.assertNotIn('nosuchthing', diff)
|
|
|
| # Test for missing newline at end of file diff output.
|
| - content_a = "Hello\n\nWorld"
|
| - content_b = "Hello\n\nWorld\n\n\n"
|
| - expected = "--- exp.txt\n+++ act.txt\n@@ -1,3 +1,5 @@\n Hello\n \n-World\n\ No newline at end of file\n+World\n+\n+\n"
|
| + content_a = 'Hello\n\nWorld'
|
| + content_b = 'Hello\n\nWorld\n\n\n'
|
| + expected = '--- exp.txt\n+++ act.txt\n@@ -1,3 +1,5 @@\n Hello\n \n-World\n\ No newline at end of file\n+World\n+\n+\n'
|
| self.assertEqual(expected, port.diff_text(content_a, content_b, 'exp.txt', 'act.txt'))
|
|
|
| def test_setup_test_run(self):
|
| @@ -220,9 +222,14 @@ class PortTest(unittest.TestCase):
|
|
|
| def test_nonexistant_expectations(self):
|
| port = self.make_port(port_name='foo')
|
| - port.expectations_files = lambda: ['/mock-checkout/third_party/WebKit/LayoutTests/platform/exists/TestExpectations', '/mock-checkout/third_party/WebKit/LayoutTests/platform/nonexistant/TestExpectations']
|
| + port.expectations_files = lambda: [
|
| + '/mock-checkout/third_party/WebKit/LayoutTests/platform/exists/TestExpectations',
|
| + '/mock-checkout/third_party/WebKit/LayoutTests/platform/nonexistant/TestExpectations']
|
| port._filesystem.write_text_file('/mock-checkout/third_party/WebKit/LayoutTests/platform/exists/TestExpectations', '')
|
| - self.assertEqual('\n'.join(port.expectations_dict().keys()), '/mock-checkout/third_party/WebKit/LayoutTests/platform/exists/TestExpectations')
|
| + self.assertEqual(
|
| + '\n'.join(
|
| + port.expectations_dict().keys()),
|
| + '/mock-checkout/third_party/WebKit/LayoutTests/platform/exists/TestExpectations')
|
|
|
| def test_additional_expectations(self):
|
| port = self.make_port(port_name='foo')
|
| @@ -302,27 +309,30 @@ class PortTest(unittest.TestCase):
|
|
|
| def test_parse_reftest_list(self):
|
| port = self.make_port(with_tests=True)
|
| - port.host.filesystem.files['bar/reftest.list'] = "\n".join(["== test.html test-ref.html",
|
| - "",
|
| - "# some comment",
|
| - "!= test-2.html test-notref.html # more comments",
|
| - "== test-3.html test-ref.html",
|
| - "== test-3.html test-ref2.html",
|
| - "!= test-3.html test-notref.html",
|
| - "fuzzy(80,500) == test-3 test-ref.html"])
|
| + port.host.filesystem.files['bar/reftest.list'] = '\n'.join(['== test.html test-ref.html',
|
| + '',
|
| + '# some comment',
|
| + '!= test-2.html test-notref.html # more comments',
|
| + '== test-3.html test-ref.html',
|
| + '== test-3.html test-ref2.html',
|
| + '!= test-3.html test-notref.html',
|
| + 'fuzzy(80,500) == test-3 test-ref.html'])
|
|
|
| # Note that we don't support the syntax in the last line; the code should ignore it, rather than crashing.
|
|
|
| reftest_list = Port._parse_reftest_list(port.host.filesystem, 'bar')
|
| self.assertEqual(reftest_list, {'bar/test.html': [('==', 'bar/test-ref.html')],
|
| - 'bar/test-2.html': [('!=', 'bar/test-notref.html')],
|
| - 'bar/test-3.html': [('==', 'bar/test-ref.html'), ('==', 'bar/test-ref2.html'), ('!=', 'bar/test-notref.html')]})
|
| + 'bar/test-2.html': [('!=', 'bar/test-notref.html')],
|
| + 'bar/test-3.html': [('==', 'bar/test-ref.html'), ('==', 'bar/test-ref2.html'), ('!=', 'bar/test-notref.html')]})
|
|
|
| def test_reference_files(self):
|
| port = self.make_port(with_tests=True)
|
| - self.assertEqual(port.reference_files('passes/svgreftest.svg'), [('==', port.layout_tests_dir() + '/passes/svgreftest-expected.svg')])
|
| - self.assertEqual(port.reference_files('passes/xhtreftest.svg'), [('==', port.layout_tests_dir() + '/passes/xhtreftest-expected.html')])
|
| - self.assertEqual(port.reference_files('passes/phpreftest.php'), [('!=', port.layout_tests_dir() + '/passes/phpreftest-expected-mismatch.svg')])
|
| + self.assertEqual(port.reference_files('passes/svgreftest.svg'),
|
| + [('==', port.layout_tests_dir() + '/passes/svgreftest-expected.svg')])
|
| + self.assertEqual(port.reference_files('passes/xhtreftest.svg'),
|
| + [('==', port.layout_tests_dir() + '/passes/xhtreftest-expected.html')])
|
| + self.assertEqual(port.reference_files('passes/phpreftest.php'),
|
| + [('!=', port.layout_tests_dir() + '/passes/phpreftest-expected-mismatch.svg')])
|
|
|
| def test_operating_system(self):
|
| self.assertEqual('mac', self.make_port().operating_system())
|
| @@ -413,6 +423,7 @@ class PortTest(unittest.TestCase):
|
|
|
|
|
| class NaturalCompareTest(unittest.TestCase):
|
| +
|
| def setUp(self):
|
| self._port = TestPort(MockSystemHost())
|
|
|
| @@ -438,6 +449,7 @@ class NaturalCompareTest(unittest.TestCase):
|
|
|
|
|
| class KeyCompareTest(unittest.TestCase):
|
| +
|
| def setUp(self):
|
| self._port = TestPort(MockSystemHost())
|
|
|
| @@ -456,6 +468,7 @@ class KeyCompareTest(unittest.TestCase):
|
|
|
|
|
| class VirtualTestSuiteTest(unittest.TestCase):
|
| +
|
| def test_basic(self):
|
| suite = VirtualTestSuite('suite', 'base/foo', ['--args'])
|
| self.assertEqual(suite.name, 'virtual/suite/base/foo')
|
|
|