| OLD | NEW |
| 1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 from webkitpy.common.system.outputcapture import OutputCapture | 38 from webkitpy.common.system.outputcapture import OutputCapture |
| 39 from webkitpy.common.system.path import abspath_to_uri | 39 from webkitpy.common.system.path import abspath_to_uri |
| 40 from webkitpy.tool.mocktool import MockOptions | 40 from webkitpy.tool.mocktool import MockOptions |
| 41 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 | 41 from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 |
| 42 from webkitpy.common.system.systemhost_mock import MockSystemHost | 42 from webkitpy.common.system.systemhost_mock import MockSystemHost |
| 43 | 43 |
| 44 from webkitpy.layout_tests.port import Port, Driver, DriverOutput | 44 from webkitpy.layout_tests.port import Port, Driver, DriverOutput |
| 45 from webkitpy.layout_tests.port.base import VirtualTestSuite | 45 from webkitpy.layout_tests.port.base import VirtualTestSuite |
| 46 from webkitpy.layout_tests.port.test import add_unit_tests_to_mock_filesystem, T
estPort | 46 from webkitpy.layout_tests.port.test import add_unit_tests_to_mock_filesystem, T
estPort |
| 47 | 47 |
| 48 |
| 48 class PortTest(unittest.TestCase): | 49 class PortTest(unittest.TestCase): |
| 50 |
| 49 def make_port(self, executive=None, with_tests=False, port_name=None, **kwar
gs): | 51 def make_port(self, executive=None, with_tests=False, port_name=None, **kwar
gs): |
| 50 host = MockSystemHost() | 52 host = MockSystemHost() |
| 51 if executive: | 53 if executive: |
| 52 host.executive = executive | 54 host.executive = executive |
| 53 if with_tests: | 55 if with_tests: |
| 54 add_unit_tests_to_mock_filesystem(host.filesystem) | 56 add_unit_tests_to_mock_filesystem(host.filesystem) |
| 55 return TestPort(host, **kwargs) | 57 return TestPort(host, **kwargs) |
| 56 return Port(host, port_name or 'baseport', **kwargs) | 58 return Port(host, port_name or 'baseport', **kwargs) |
| 57 | 59 |
| 58 def test_default_child_processes(self): | 60 def test_default_child_processes(self): |
| 59 port = self.make_port() | 61 port = self.make_port() |
| 60 self.assertIsNotNone(port.default_child_processes()) | 62 self.assertIsNotNone(port.default_child_processes()) |
| 61 | 63 |
| 62 def test_format_wdiff_output_as_html(self): | 64 def test_format_wdiff_output_as_html(self): |
| 63 output = "OUTPUT %s %s %s" % (Port._WDIFF_DEL, Port._WDIFF_ADD, Port._WD
IFF_END) | 65 output = 'OUTPUT %s %s %s' % (Port._WDIFF_DEL, Port._WDIFF_ADD, Port._WD
IFF_END) |
| 64 html = self.make_port()._format_wdiff_output_as_html(output) | 66 html = self.make_port()._format_wdiff_output_as_html(output) |
| 65 expected_html = "<head><style>.del { background: #faa; } .add { backgrou
nd: #afa; }</style></head><pre>OUTPUT <span class=del> <span class=add> </span><
/pre>" | 67 expected_html = '<head><style>.del { background: #faa; } .add { backgrou
nd: #afa; }</style></head><pre>OUTPUT <span class=del> <span class=add> </span><
/pre>' |
| 66 self.assertEqual(html, expected_html) | 68 self.assertEqual(html, expected_html) |
| 67 | 69 |
| 68 def test_wdiff_command(self): | 70 def test_wdiff_command(self): |
| 69 port = self.make_port() | 71 port = self.make_port() |
| 70 port._path_to_wdiff = lambda: "/path/to/wdiff" | 72 port._path_to_wdiff = lambda: '/path/to/wdiff' |
| 71 command = port._wdiff_command("/actual/path", "/expected/path") | 73 command = port._wdiff_command('/actual/path', '/expected/path') |
| 72 expected_command = [ | 74 expected_command = [ |
| 73 "/path/to/wdiff", | 75 '/path/to/wdiff', |
| 74 "--start-delete=##WDIFF_DEL##", | 76 '--start-delete=##WDIFF_DEL##', |
| 75 "--end-delete=##WDIFF_END##", | 77 '--end-delete=##WDIFF_END##', |
| 76 "--start-insert=##WDIFF_ADD##", | 78 '--start-insert=##WDIFF_ADD##', |
| 77 "--end-insert=##WDIFF_END##", | 79 '--end-insert=##WDIFF_END##', |
| 78 "/actual/path", | 80 '/actual/path', |
| 79 "/expected/path", | 81 '/expected/path', |
| 80 ] | 82 ] |
| 81 self.assertEqual(command, expected_command) | 83 self.assertEqual(command, expected_command) |
| 82 | 84 |
| 83 def _file_with_contents(self, contents, encoding="utf-8"): | 85 def _file_with_contents(self, contents, encoding='utf-8'): |
| 84 new_file = tempfile.NamedTemporaryFile() | 86 new_file = tempfile.NamedTemporaryFile() |
| 85 new_file.write(contents.encode(encoding)) | 87 new_file.write(contents.encode(encoding)) |
| 86 new_file.flush() | 88 new_file.flush() |
| 87 return new_file | 89 return new_file |
| 88 | 90 |
| 89 def test_pretty_patch_os_error(self): | 91 def test_pretty_patch_os_error(self): |
| 90 port = self.make_port(executive=executive_mock.MockExecutive2(exception=
OSError)) | 92 port = self.make_port(executive=executive_mock.MockExecutive2(exception=
OSError)) |
| 91 oc = OutputCapture() | 93 oc = OutputCapture() |
| 92 oc.capture_output() | 94 oc.capture_output() |
| 93 self.assertEqual(port.pretty_patch_text("patch.txt"), | 95 self.assertEqual(port.pretty_patch_text('patch.txt'), |
| 94 port._pretty_patch_error_html) | 96 port._pretty_patch_error_html) |
| 95 | 97 |
| 96 # This tests repeated calls to make sure we cache the result. | 98 # This tests repeated calls to make sure we cache the result. |
| 97 self.assertEqual(port.pretty_patch_text("patch.txt"), | 99 self.assertEqual(port.pretty_patch_text('patch.txt'), |
| 98 port._pretty_patch_error_html) | 100 port._pretty_patch_error_html) |
| 99 oc.restore_output() | 101 oc.restore_output() |
| 100 | 102 |
| 101 def test_pretty_patch_script_error(self): | 103 def test_pretty_patch_script_error(self): |
| 102 # FIXME: This is some ugly white-box test hacking ... | 104 # FIXME: This is some ugly white-box test hacking ... |
| 103 port = self.make_port(executive=executive_mock.MockExecutive2(exception=
ScriptError)) | 105 port = self.make_port(executive=executive_mock.MockExecutive2(exception=
ScriptError)) |
| 104 port._pretty_patch_available = True | 106 port._pretty_patch_available = True |
| 105 self.assertEqual(port.pretty_patch_text("patch.txt"), | 107 self.assertEqual(port.pretty_patch_text('patch.txt'), |
| 106 port._pretty_patch_error_html) | 108 port._pretty_patch_error_html) |
| 107 | 109 |
| 108 # This tests repeated calls to make sure we cache the result. | 110 # This tests repeated calls to make sure we cache the result. |
| 109 self.assertEqual(port.pretty_patch_text("patch.txt"), | 111 self.assertEqual(port.pretty_patch_text('patch.txt'), |
| 110 port._pretty_patch_error_html) | 112 port._pretty_patch_error_html) |
| 111 | 113 |
| 112 def test_wdiff_text(self): | 114 def test_wdiff_text(self): |
| 113 port = self.make_port() | 115 port = self.make_port() |
| 114 port.wdiff_available = lambda: True | 116 port.wdiff_available = lambda: True |
| 115 port._run_wdiff = lambda a, b: 'PASS' | 117 port._run_wdiff = lambda a, b: 'PASS' |
| 116 self.assertEqual('PASS', port.wdiff_text(None, None)) | 118 self.assertEqual('PASS', port.wdiff_text(None, None)) |
| 117 | 119 |
| 118 def test_diff_text(self): | 120 def test_diff_text(self): |
| 119 port = self.make_port() | 121 port = self.make_port() |
| (...skipping 16 matching lines...) Expand all Loading... |
| 136 | 138 |
| 137 # And make sure we actually get diff output. | 139 # And make sure we actually get diff output. |
| 138 diff = port.diff_text('foo', 'bar', 'exp.txt', 'act.txt') | 140 diff = port.diff_text('foo', 'bar', 'exp.txt', 'act.txt') |
| 139 self.assertIn('foo', diff) | 141 self.assertIn('foo', diff) |
| 140 self.assertIn('bar', diff) | 142 self.assertIn('bar', diff) |
| 141 self.assertIn('exp.txt', diff) | 143 self.assertIn('exp.txt', diff) |
| 142 self.assertIn('act.txt', diff) | 144 self.assertIn('act.txt', diff) |
| 143 self.assertNotIn('nosuchthing', diff) | 145 self.assertNotIn('nosuchthing', diff) |
| 144 | 146 |
| 145 # Test for missing newline at end of file diff output. | 147 # Test for missing newline at end of file diff output. |
| 146 content_a = "Hello\n\nWorld" | 148 content_a = 'Hello\n\nWorld' |
| 147 content_b = "Hello\n\nWorld\n\n\n" | 149 content_b = 'Hello\n\nWorld\n\n\n' |
| 148 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" | 150 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' |
| 149 self.assertEqual(expected, port.diff_text(content_a, content_b, 'exp.txt
', 'act.txt')) | 151 self.assertEqual(expected, port.diff_text(content_a, content_b, 'exp.txt
', 'act.txt')) |
| 150 | 152 |
| 151 def test_setup_test_run(self): | 153 def test_setup_test_run(self): |
| 152 port = self.make_port() | 154 port = self.make_port() |
| 153 # This routine is a no-op. We just test it for coverage. | 155 # This routine is a no-op. We just test it for coverage. |
| 154 port.setup_test_run() | 156 port.setup_test_run() |
| 155 | 157 |
| 156 def test_test_dirs(self): | 158 def test_test_dirs(self): |
| 157 port = self.make_port() | 159 port = self.make_port() |
| 158 port.host.filesystem.write_text_file(port.layout_tests_dir() + '/canvas/
test', '') | 160 port.host.filesystem.write_text_file(port.layout_tests_dir() + '/canvas/
test', '') |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 215 |
| 214 # Multiple additional platform directories | 216 # Multiple additional platform directories |
| 215 port._options.additional_platform_directory = ['/foo', '/tmp/local-basel
ines'] | 217 port._options.additional_platform_directory = ['/foo', '/tmp/local-basel
ines'] |
| 216 self.assertEqual( | 218 self.assertEqual( |
| 217 port.expected_baselines(test_file, '.txt'), | 219 port.expected_baselines(test_file, '.txt'), |
| 218 [('/tmp/local-baselines', 'fast/test-expected.txt')]) | 220 [('/tmp/local-baselines', 'fast/test-expected.txt')]) |
| 219 self.assertEqual(port.baseline_path(), '/foo') | 221 self.assertEqual(port.baseline_path(), '/foo') |
| 220 | 222 |
| 221 def test_nonexistant_expectations(self): | 223 def test_nonexistant_expectations(self): |
| 222 port = self.make_port(port_name='foo') | 224 port = self.make_port(port_name='foo') |
| 223 port.expectations_files = lambda: ['/mock-checkout/third_party/WebKit/La
youtTests/platform/exists/TestExpectations', '/mock-checkout/third_party/WebKit/
LayoutTests/platform/nonexistant/TestExpectations'] | 225 port.expectations_files = lambda: [ |
| 226 '/mock-checkout/third_party/WebKit/LayoutTests/platform/exists/TestE
xpectations', |
| 227 '/mock-checkout/third_party/WebKit/LayoutTests/platform/nonexistant/
TestExpectations'] |
| 224 port._filesystem.write_text_file('/mock-checkout/third_party/WebKit/Layo
utTests/platform/exists/TestExpectations', '') | 228 port._filesystem.write_text_file('/mock-checkout/third_party/WebKit/Layo
utTests/platform/exists/TestExpectations', '') |
| 225 self.assertEqual('\n'.join(port.expectations_dict().keys()), '/mock-chec
kout/third_party/WebKit/LayoutTests/platform/exists/TestExpectations') | 229 self.assertEqual( |
| 230 '\n'.join( |
| 231 port.expectations_dict().keys()), |
| 232 '/mock-checkout/third_party/WebKit/LayoutTests/platform/exists/TestE
xpectations') |
| 226 | 233 |
| 227 def test_additional_expectations(self): | 234 def test_additional_expectations(self): |
| 228 port = self.make_port(port_name='foo') | 235 port = self.make_port(port_name='foo') |
| 229 port.port_name = 'foo' | 236 port.port_name = 'foo' |
| 230 port._filesystem.write_text_file('/mock-checkout/third_party/WebKit/Layo
utTests/platform/foo/TestExpectations', '') | 237 port._filesystem.write_text_file('/mock-checkout/third_party/WebKit/Layo
utTests/platform/foo/TestExpectations', '') |
| 231 port._filesystem.write_text_file( | 238 port._filesystem.write_text_file( |
| 232 '/tmp/additional-expectations-1.txt', 'content1\n') | 239 '/tmp/additional-expectations-1.txt', 'content1\n') |
| 233 port._filesystem.write_text_file( | 240 port._filesystem.write_text_file( |
| 234 '/tmp/additional-expectations-2.txt', 'content2\n') | 241 '/tmp/additional-expectations-2.txt', 'content2\n') |
| 235 | 242 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 self.assertFalse(Port.is_test_file(filesystem, '', 'foo-expected-mismatc
h.xhtml')) | 302 self.assertFalse(Port.is_test_file(filesystem, '', 'foo-expected-mismatc
h.xhtml')) |
| 296 self.assertFalse(Port.is_test_file(filesystem, '', 'foo-ref.html')) | 303 self.assertFalse(Port.is_test_file(filesystem, '', 'foo-ref.html')) |
| 297 self.assertFalse(Port.is_test_file(filesystem, '', 'foo-notref.html')) | 304 self.assertFalse(Port.is_test_file(filesystem, '', 'foo-notref.html')) |
| 298 self.assertFalse(Port.is_test_file(filesystem, '', 'foo-notref.xht')) | 305 self.assertFalse(Port.is_test_file(filesystem, '', 'foo-notref.xht')) |
| 299 self.assertFalse(Port.is_test_file(filesystem, '', 'foo-ref.xhtml')) | 306 self.assertFalse(Port.is_test_file(filesystem, '', 'foo-ref.xhtml')) |
| 300 self.assertFalse(Port.is_test_file(filesystem, '', 'ref-foo.html')) | 307 self.assertFalse(Port.is_test_file(filesystem, '', 'ref-foo.html')) |
| 301 self.assertFalse(Port.is_test_file(filesystem, '', 'notref-foo.xhr')) | 308 self.assertFalse(Port.is_test_file(filesystem, '', 'notref-foo.xhr')) |
| 302 | 309 |
| 303 def test_parse_reftest_list(self): | 310 def test_parse_reftest_list(self): |
| 304 port = self.make_port(with_tests=True) | 311 port = self.make_port(with_tests=True) |
| 305 port.host.filesystem.files['bar/reftest.list'] = "\n".join(["== test.htm
l test-ref.html", | 312 port.host.filesystem.files['bar/reftest.list'] = '\n'.join(['== test.htm
l test-ref.html', |
| 306 "", | 313 '', |
| 307 "# some comment", | 314 '# some comm
ent', |
| 308 "!= test-2.html test-notref.html # more comments", | 315 '!= test-2.h
tml test-notref.html # more comments', |
| 309 "== test-3.html test-ref.html", | 316 '== test-3.h
tml test-ref.html', |
| 310 "== test-3.html test-ref2.html", | 317 '== test-3.h
tml test-ref2.html', |
| 311 "!= test-3.html test-notref.html", | 318 '!= test-3.h
tml test-notref.html', |
| 312 "fuzzy(80,500) == test-3 test-ref.html"]) | 319 'fuzzy(80,50
0) == test-3 test-ref.html']) |
| 313 | 320 |
| 314 # Note that we don't support the syntax in the last line; the code shoul
d ignore it, rather than crashing. | 321 # Note that we don't support the syntax in the last line; the code shoul
d ignore it, rather than crashing. |
| 315 | 322 |
| 316 reftest_list = Port._parse_reftest_list(port.host.filesystem, 'bar') | 323 reftest_list = Port._parse_reftest_list(port.host.filesystem, 'bar') |
| 317 self.assertEqual(reftest_list, {'bar/test.html': [('==', 'bar/test-ref.h
tml')], | 324 self.assertEqual(reftest_list, {'bar/test.html': [('==', 'bar/test-ref.h
tml')], |
| 318 'bar/test-2.html': [('!=', 'bar/test-notref.html')], | 325 'bar/test-2.html': [('!=', 'bar/test-not
ref.html')], |
| 319 'bar/test-3.html': [('==', 'bar/test-ref.html'), ('==', 'bar/test-re
f2.html'), ('!=', 'bar/test-notref.html')]}) | 326 'bar/test-3.html': [('==', 'bar/test-ref
.html'), ('==', 'bar/test-ref2.html'), ('!=', 'bar/test-notref.html')]}) |
| 320 | 327 |
| 321 def test_reference_files(self): | 328 def test_reference_files(self): |
| 322 port = self.make_port(with_tests=True) | 329 port = self.make_port(with_tests=True) |
| 323 self.assertEqual(port.reference_files('passes/svgreftest.svg'), [('==',
port.layout_tests_dir() + '/passes/svgreftest-expected.svg')]) | 330 self.assertEqual(port.reference_files('passes/svgreftest.svg'), |
| 324 self.assertEqual(port.reference_files('passes/xhtreftest.svg'), [('==',
port.layout_tests_dir() + '/passes/xhtreftest-expected.html')]) | 331 [('==', port.layout_tests_dir() + '/passes/svgreftest-e
xpected.svg')]) |
| 325 self.assertEqual(port.reference_files('passes/phpreftest.php'), [('!=',
port.layout_tests_dir() + '/passes/phpreftest-expected-mismatch.svg')]) | 332 self.assertEqual(port.reference_files('passes/xhtreftest.svg'), |
| 333 [('==', port.layout_tests_dir() + '/passes/xhtreftest-e
xpected.html')]) |
| 334 self.assertEqual(port.reference_files('passes/phpreftest.php'), |
| 335 [('!=', port.layout_tests_dir() + '/passes/phpreftest-e
xpected-mismatch.svg')]) |
| 326 | 336 |
| 327 def test_operating_system(self): | 337 def test_operating_system(self): |
| 328 self.assertEqual('mac', self.make_port().operating_system()) | 338 self.assertEqual('mac', self.make_port().operating_system()) |
| 329 | 339 |
| 330 def test_http_server_supports_ipv6(self): | 340 def test_http_server_supports_ipv6(self): |
| 331 port = self.make_port() | 341 port = self.make_port() |
| 332 self.assertTrue(port.http_server_supports_ipv6()) | 342 self.assertTrue(port.http_server_supports_ipv6()) |
| 333 port.host.platform.os_name = 'cygwin' | 343 port.host.platform.os_name = 'cygwin' |
| 334 self.assertFalse(port.http_server_supports_ipv6()) | 344 self.assertFalse(port.http_server_supports_ipv6()) |
| 335 port.host.platform.os_name = 'win' | 345 port.host.platform.os_name = 'win' |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 def test_build_path(self): | 416 def test_build_path(self): |
| 407 port = self.make_port(options=optparse.Values({'build_directory': '/my-b
uild-directory/'})) | 417 port = self.make_port(options=optparse.Values({'build_directory': '/my-b
uild-directory/'})) |
| 408 self.assertEqual(port._build_path(), '/my-build-directory/Release') | 418 self.assertEqual(port._build_path(), '/my-build-directory/Release') |
| 409 | 419 |
| 410 def test_dont_require_http_server(self): | 420 def test_dont_require_http_server(self): |
| 411 port = self.make_port() | 421 port = self.make_port() |
| 412 self.assertEqual(port.requires_http_server(), False) | 422 self.assertEqual(port.requires_http_server(), False) |
| 413 | 423 |
| 414 | 424 |
| 415 class NaturalCompareTest(unittest.TestCase): | 425 class NaturalCompareTest(unittest.TestCase): |
| 426 |
| 416 def setUp(self): | 427 def setUp(self): |
| 417 self._port = TestPort(MockSystemHost()) | 428 self._port = TestPort(MockSystemHost()) |
| 418 | 429 |
| 419 def assert_cmp(self, x, y, result): | 430 def assert_cmp(self, x, y, result): |
| 420 self.assertEqual(cmp(self._port._natural_sort_key(x), self._port._natura
l_sort_key(y)), result) | 431 self.assertEqual(cmp(self._port._natural_sort_key(x), self._port._natura
l_sort_key(y)), result) |
| 421 | 432 |
| 422 def test_natural_compare(self): | 433 def test_natural_compare(self): |
| 423 self.assert_cmp('a', 'a', 0) | 434 self.assert_cmp('a', 'a', 0) |
| 424 self.assert_cmp('ab', 'a', 1) | 435 self.assert_cmp('ab', 'a', 1) |
| 425 self.assert_cmp('a', 'ab', -1) | 436 self.assert_cmp('a', 'ab', -1) |
| 426 self.assert_cmp('', '', 0) | 437 self.assert_cmp('', '', 0) |
| 427 self.assert_cmp('', 'ab', -1) | 438 self.assert_cmp('', 'ab', -1) |
| 428 self.assert_cmp('1', '2', -1) | 439 self.assert_cmp('1', '2', -1) |
| 429 self.assert_cmp('2', '1', 1) | 440 self.assert_cmp('2', '1', 1) |
| 430 self.assert_cmp('1', '10', -1) | 441 self.assert_cmp('1', '10', -1) |
| 431 self.assert_cmp('2', '10', -1) | 442 self.assert_cmp('2', '10', -1) |
| 432 self.assert_cmp('foo_1.html', 'foo_2.html', -1) | 443 self.assert_cmp('foo_1.html', 'foo_2.html', -1) |
| 433 self.assert_cmp('foo_1.1.html', 'foo_2.html', -1) | 444 self.assert_cmp('foo_1.1.html', 'foo_2.html', -1) |
| 434 self.assert_cmp('foo_1.html', 'foo_10.html', -1) | 445 self.assert_cmp('foo_1.html', 'foo_10.html', -1) |
| 435 self.assert_cmp('foo_2.html', 'foo_10.html', -1) | 446 self.assert_cmp('foo_2.html', 'foo_10.html', -1) |
| 436 self.assert_cmp('foo_23.html', 'foo_10.html', 1) | 447 self.assert_cmp('foo_23.html', 'foo_10.html', 1) |
| 437 self.assert_cmp('foo_23.html', 'foo_100.html', -1) | 448 self.assert_cmp('foo_23.html', 'foo_100.html', -1) |
| 438 | 449 |
| 439 | 450 |
| 440 class KeyCompareTest(unittest.TestCase): | 451 class KeyCompareTest(unittest.TestCase): |
| 452 |
| 441 def setUp(self): | 453 def setUp(self): |
| 442 self._port = TestPort(MockSystemHost()) | 454 self._port = TestPort(MockSystemHost()) |
| 443 | 455 |
| 444 def assert_cmp(self, x, y, result): | 456 def assert_cmp(self, x, y, result): |
| 445 self.assertEqual(cmp(self._port.test_key(x), self._port.test_key(y)), re
sult) | 457 self.assertEqual(cmp(self._port.test_key(x), self._port.test_key(y)), re
sult) |
| 446 | 458 |
| 447 def test_test_key(self): | 459 def test_test_key(self): |
| 448 self.assert_cmp('/a', '/a', 0) | 460 self.assert_cmp('/a', '/a', 0) |
| 449 self.assert_cmp('/a', '/b', -1) | 461 self.assert_cmp('/a', '/b', -1) |
| 450 self.assert_cmp('/a2', '/a10', -1) | 462 self.assert_cmp('/a2', '/a10', -1) |
| 451 self.assert_cmp('/a2/foo', '/a10/foo', -1) | 463 self.assert_cmp('/a2/foo', '/a10/foo', -1) |
| 452 self.assert_cmp('/a/foo11', '/a/foo2', 1) | 464 self.assert_cmp('/a/foo11', '/a/foo2', 1) |
| 453 self.assert_cmp('/ab', '/a/a/b', -1) | 465 self.assert_cmp('/ab', '/a/a/b', -1) |
| 454 self.assert_cmp('/a/a/b', '/ab', 1) | 466 self.assert_cmp('/a/a/b', '/ab', 1) |
| 455 self.assert_cmp('/foo-bar/baz', '/foo/baz', -1) | 467 self.assert_cmp('/foo-bar/baz', '/foo/baz', -1) |
| 456 | 468 |
| 457 | 469 |
| 458 class VirtualTestSuiteTest(unittest.TestCase): | 470 class VirtualTestSuiteTest(unittest.TestCase): |
| 471 |
| 459 def test_basic(self): | 472 def test_basic(self): |
| 460 suite = VirtualTestSuite('suite', 'base/foo', ['--args']) | 473 suite = VirtualTestSuite('suite', 'base/foo', ['--args']) |
| 461 self.assertEqual(suite.name, 'virtual/suite/base/foo') | 474 self.assertEqual(suite.name, 'virtual/suite/base/foo') |
| 462 self.assertEqual(suite.base, 'base/foo') | 475 self.assertEqual(suite.base, 'base/foo') |
| 463 self.assertEqual(suite.args, ['--args']) | 476 self.assertEqual(suite.args, ['--args']) |
| 464 | 477 |
| 465 def test_no_slash(self): | 478 def test_no_slash(self): |
| 466 suite = VirtualTestSuite('suite/bar', 'base/foo', ['--args']) | 479 suite = VirtualTestSuite('suite/bar', 'base/foo', ['--args']) |
| 467 self.assertFalse(hasattr(suite, 'name')) | 480 self.assertFalse(hasattr(suite, 'name')) |
| 468 self.assertFalse(hasattr(suite, 'base')) | 481 self.assertFalse(hasattr(suite, 'base')) |
| 469 self.assertFalse(hasattr(suite, 'args')) | 482 self.assertFalse(hasattr(suite, 'args')) |
| 470 | 483 |
| 471 def test_legacy(self): | 484 def test_legacy(self): |
| 472 suite = VirtualTestSuite('suite/bar', 'base/foo', ['--args'], use_legacy
_naming=True) | 485 suite = VirtualTestSuite('suite/bar', 'base/foo', ['--args'], use_legacy
_naming=True) |
| 473 self.assertEqual(suite.name, 'virtual/suite/bar') | 486 self.assertEqual(suite.name, 'virtual/suite/bar') |
| 474 self.assertEqual(suite.base, 'base/foo') | 487 self.assertEqual(suite.base, 'base/foo') |
| 475 self.assertEqual(suite.args, ['--args']) | 488 self.assertEqual(suite.args, ['--args']) |
| OLD | NEW |