Changeset 76642 in webkit
- Timestamp:
- Jan 25, 2011 2:52:17 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r76620 r76642 1 2011-01-25 Dirk Pranke <dpranke@chromium.org> 2 3 Reviewed by Tony Chang. 4 5 Minor bug fixes and cleanup for filesystem wrappers, port/* test 6 classes, test_expectations.py. This change adds "test-win" and 7 "test-mac" variants to the test port so that we can better test 8 rebaselining, and adds a MockUser() object for reuse in testing. 9 10 https://bugs.webkit.org/show_bug.cgi?id=53036 11 12 * Scripts/webkitpy/common/system/filesystem.py: 13 * Scripts/webkitpy/common/system/filesystem_mock.py: 14 * Scripts/webkitpy/layout_tests/layout_package/test_expectations.py: 15 * Scripts/webkitpy/layout_tests/port/factory.py: 16 * Scripts/webkitpy/layout_tests/port/base.py: 17 * Scripts/webkitpy/layout_tests/port/test.py: 18 * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py: 19 * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py: 20 * Scripts/webkitpy/tool/mocktool.py: 21 1 22 2011-01-25 Tony Chang <tony@chromium.org> 2 23 -
trunk/Tools/Scripts/webkitpy/common/system/filesystem.py
r76199 r76642 166 166 raise 167 167 168 def move(self, s rc, dest):169 shutil.move(s rc, dest)168 def move(self, source, destination): 169 shutil.move(source, destination) 170 170 171 171 def mtime(self, path): -
trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py
r76184 r76642 70 70 71 71 self.files[destination] = self.files[source] 72 self.written_files[destination] = self.files[source] 72 73 73 74 def dirname(self, path): … … 197 198 pass 198 199 199 def move(self, src, dst): 200 if self.files[src] is None: 201 self._raise_not_found(src) 202 self.files[dst] = self.files[src] 203 self.files[src] = None 200 def move(self, source, destination): 201 if self.files[source] is None: 202 self._raise_not_found(source) 203 self.files[destination] = self.files[source] 204 self.written_files[destination] = self.files[destination] 205 self.files[source] = None 206 self.written_files[source] = None 204 207 205 208 def normpath(self, path): 206 209 return path 207 210 208 def open_binary_tempfile(self, suffix ):211 def open_binary_tempfile(self, suffix=''): 209 212 path = self._mktemp(suffix) 210 return WritableFileObject(self, path), path213 return (WritableFileObject(self, path), path) 211 214 212 215 def open_text_file_for_writing(self, path, append=False): … … 226 229 self._raise_not_found(path) 227 230 self.files[path] = None 231 self.written_files[path] = None 228 232 229 233 def rmtree(self, path): -
trunk/Tools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
r76288 r76642 90 90 Args: 91 91 port: handle to object containing platform-specific functionality 92 test : list of all of the test files92 tests: list of all of the test files 93 93 expectations: test expectations as a string 94 94 test_platform_name: name of the platform to match expectations -
trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py
r76200 r76642 583 583 Basically this string should contain the equivalent of a 584 584 test_expectations file. See test_expectations.py for more details.""" 585 r aise NotImplementedError('Port.test_expectations')585 return self._filesystem.read_text_file(self.path_to_test_expectations_file()) 586 586 587 587 def test_expectations_overrides(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/factory.py
r68063 r76642 71 71 sys.platform) 72 72 73 if port_to_use == 'test':73 if port_to_use.startswith('test'): 74 74 import test 75 75 maker = test.TestPort -
trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py
r76184 r76642 34 34 35 35 from webkitpy.common.system import filesystem_mock 36 from webkitpy.tool import mocktool 36 37 37 38 from webkitpy.layout_tests.layout_package import test_output … … 193 194 """Test implementation of the Port interface.""" 194 195 195 def __init__(self, **kwargs): 196 # FIXME: what happens if we're not passed in the test filesystem 197 # and the tests don't match what's in the filesystem? 198 # 199 # We'll leave as is for now to avoid unnecessary dependencies while 200 # converting all of the unit tests over to using 201 # unit_test_filesystem(). If things get out of sync the tests should 202 # fail in fairly obvious ways. Eventually we want to just do: 203 # 204 # assert kwargs['filesystem']._tests 205 # self._tests = kwargs['filesystem']._tests 206 207 if 'filesystem' not in kwargs or kwargs['filesystem'] is None: 208 kwargs['filesystem'] = unit_test_filesystem() 209 self._tests = kwargs['filesystem']._tests 210 else: 211 self._tests = unit_test_list() 212 213 kwargs.setdefault('port_name', 'test') 214 base.Port.__init__(self, **kwargs) 196 def __init__(self, port_name=None, user=None, filesystem=None, **kwargs): 197 if not filesystem: 198 filesystem = unit_test_filesystem() 199 200 assert filesystem._tests 201 self._tests = filesystem._tests 202 203 if not user: 204 user = mocktool.MockUser() 205 206 if not port_name or port_name == 'test': 207 port_name = 'test-mac' 208 209 self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt' 210 base.Port.__init__(self, port_name=port_name, filesystem=filesystem, user=user, 211 **kwargs) 215 212 216 213 def baseline_path(self): … … 265 262 return ('mac', 'win') 266 263 267 def test_expectations(self):268 return self._ filesystem.read_text_file(LAYOUT_TEST_DIR + '/platform/test/test_expectations.txt')264 def path_to_test_expectations_file(self): 265 return self._expectations_path 269 266 270 267 def test_platform_name(self): 268 if self._name == 'test-win': 269 return 'win' 271 270 return 'mac' 272 271 … … 275 274 276 275 def test_platform_name_to_name(self, test_platform_name): 277 return test_platform_name 276 name_map = { 277 'mac': 'test-mac', 278 'win': 'test-win', 279 } 280 return name_map[test_platform_name] 278 281 279 282 def version(self): -
trunk/Tools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests_unittest.py
r76059 r76642 33 33 34 34 from webkitpy.tool import mocktool 35 from webkitpy.common.system import filesystem_mock36 35 from webkitpy.common.system.executive import Executive, ScriptError 37 36 … … 89 88 options = mocktool.MockOptions(configuration=None, 90 89 html_directory=None) 91 filesystem = filesystem_mock.MockFileSystem()90 filesystem = port.unit_test_filesystem() 92 91 host_port_obj = port.get('test', options, filesystem=filesystem) 93 92 target_options = options 94 93 target_port_obj = port.get('test', target_options, filesystem=filesystem) 95 platform = 'test'94 platform = target_port_obj.test_platform_name() 96 95 return rebaseline_chromium_webkit_tests.Rebaseliner( 97 96 host_port_obj, target_port_obj, platform, options) … … 132 131 def make_generator(self, files, tests): 133 132 options = mocktool.MockOptions(configuration=None, html_directory='/tmp') 134 host_port = port.get('test', options, filesystem= filesystem_mock.MockFileSystem(files))133 host_port = port.get('test', options, filesystem=port.unit_test_filesystem(files)) 135 134 generator = rebaseline_chromium_webkit_tests.HtmlGenerator( 136 135 host_port, -
trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py
r76398 r76642 46 46 from webkitpy.common.system import outputcapture 47 47 from webkitpy.common.system import filesystem_mock 48 from webkitpy. common.system import user48 from webkitpy.tool import mocktool 49 49 from webkitpy.layout_tests import port 50 50 from webkitpy.layout_tests import run_webkit_tests … … 55 55 56 56 from webkitpy.thirdparty.mock import Mock 57 58 59 class MockUser():60 def __init__(self):61 self.url = None62 63 def open_url(self, url):64 self.url = url65 57 66 58 … … 94 86 if not port_obj: 95 87 port_obj = port.get(port_name=options.platform, options=options, 96 user= MockUser(), filesystem=filesystem)88 user=mocktool.MockUser(), filesystem=filesystem) 97 89 res = run_webkit_tests.run(port_obj, options, parsed_args) 98 90 return res == 0 … … 104 96 tests_included=tests_included, 105 97 print_nothing=False) 106 user = MockUser()98 user = mocktool.MockUser() 107 99 if not port_obj: 108 100 port_obj = port.get(port_name=options.platform, options=options, … … 136 128 options, parsed_args = parse_args(extra_args, tests_included=True) 137 129 138 user = MockUser()130 user = mocktool.MockUser() 139 131 140 132 test_batches = [] … … 217 209 def test_full_results_html(self): 218 210 # FIXME: verify html? 219 self.assertTrue(passing_run(['--full-results-html'])) 211 res, out, err, user = logging_run(['--full-results-html']) 212 self.assertEqual(res, 0) 220 213 221 214 def test_help_printing(self): … … 257 250 def test_lint_test_files__errors(self): 258 251 options, parsed_args = parse_args(['--lint-test-files']) 259 user = MockUser()252 user = mocktool.MockUser() 260 253 port_obj = port.get(options.platform, options=options, user=user) 261 254 port_obj.test_expectations = lambda: "# syntax error" … … 353 346 self.assertFalse(out.empty()) 354 347 self.assertFalse(err.empty()) 355 self.assertEqual(user. url, '/tmp/layout-test-results/results.html')348 self.assertEqual(user.opened_urls, ['/tmp/layout-test-results/results.html']) 356 349 357 350 def test_exit_after_n_failures(self): … … 415 408 res, out, err, user = logging_run(['--results-directory=' + str(tmpdir)], 416 409 tests_included=True, filesystem=fs) 417 self.assertEqual(user. url, fs.join(tmpdir, 'results.html'))410 self.assertEqual(user.opened_urls, [fs.join(tmpdir, 'results.html')]) 418 411 419 412 def test_results_directory_default(self): … … 423 416 # This is the default location. 424 417 res, out, err, user = logging_run(tests_included=True) 425 self.assertEqual(user. url, '/tmp/layout-test-results/results.html')418 self.assertEqual(user.opened_urls, ['/tmp/layout-test-results/results.html']) 426 419 427 420 def test_results_directory_relative(self): … … 431 424 res, out, err, user = logging_run(['--results-directory=foo'], 432 425 tests_included=True) 433 self.assertEqual(user. url, '/tmp/foo/results.html')426 self.assertEqual(user.opened_urls, ['/tmp/foo/results.html']) 434 427 435 428 def test_tolerance(self): … … 442 435 def get_port_for_run(args): 443 436 options, parsed_args = run_webkit_tests.parse_args(args) 444 test_port = ImageDiffTestPort(options=options, user= MockUser())437 test_port = ImageDiffTestPort(options=options, user=mocktool.MockUser()) 445 438 passing_run(args, port_obj=test_port, tests_included=True) 446 439 return test_port … … 512 505 self.assertEqual(len(file_list), 6) 513 506 self.assertBaselines(file_list, 514 "/platform/test /passes/image")507 "/platform/test-mac/passes/image") 515 508 self.assertBaselines(file_list, 516 "/platform/test /failures/expected/missing_image")509 "/platform/test-mac/failures/expected/missing_image") 517 510 518 511 -
trunk/Tools/Scripts/webkitpy/tool/mocktool.py
r75787 r76642 549 549 pass 550 550 551 def __init__(self): 552 self.opened_urls = [] 553 551 554 def edit(self, files): 552 555 pass … … 566 569 567 570 def open_url(self, url): 571 self.opened_urls.append(url) 568 572 if url.startswith("file://"): 569 573 log("MOCK: user.open_url: file://...")
Note: See TracChangeset
for help on using the changeset viewer.