Changeset 245287 in webkit
- Timestamp:
- May 14, 2019 10:03:18 AM (5 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r245282 r245287 1 2019-05-14 Youenn Fablet <youenn@apple.com> 2 3 Add support for webkit-test-runner options to WPT importer 4 https://bugs.webkit.org/show_bug.cgi?id=197826 5 6 Reviewed by Alex Christensen. 7 8 In case of overwriting an existing test, check if the existing test 9 contains a <!-- webkit-test-runner --> comment and insert it back if 10 needed in the new test. 11 12 For exporter, forbid creating a WPT PR if there are changes containing 13 the webkit-test-runner string. 14 15 * Scripts/webkitpy/w3c/test_converter.py: 16 (convert_for_webkit): 17 (_W3CTestConverter.__init__): 18 (_W3CTestConverter.add_webkit_test_runner_options_if_needed): 19 (_W3CTestConverter.handle_starttag): 20 (_W3CTestConverter.handle_comment): 21 (_W3CTestConverter.handle_decl): 22 (_W3CTestConverter.handle_pi): 23 * Scripts/webkitpy/w3c/test_exporter.py: 24 (WebPlatformTestExporter.write_git_patch_file): 25 (WebPlatformTestExporter.make_pull_request): 26 * Scripts/webkitpy/w3c/test_importer.py: 27 (TestImporter.webkit_test_runner_options): 28 (TestImporter): 29 (TestImporter.add_webkit_test_runner_options_to_content): 30 (TestImporter.copy_html_file): 31 (TestImporter.write_html_template): 32 (TestImporter.write_html_files_for_templated_js_tests): 33 (TestImporter.import_tests): 34 * Scripts/webkitpy/w3c/test_importer_unittest.py: 35 (test_manual_slow_test): 36 (test_webkit_test_runner_options): 37 1 38 2019-05-14 Aakash Jain <aakash_jain@apple.com> 2 39 -
trunk/Tools/Scripts/webkitpy/w3c/test_converter.py
r209012 r245287 39 39 40 40 41 def convert_for_webkit(new_path, filename, reference_support_info, host=Host(), convert_test_harness_links=True ):41 def convert_for_webkit(new_path, filename, reference_support_info, host=Host(), convert_test_harness_links=True, webkit_test_runner_options=''): 42 42 """ Converts a file's |contents| so it will function correctly in its |new_path| in Webkit. 43 43 44 44 Returns the list of modified properties and the modified text if the file was modifed, None otherwise.""" 45 45 contents = host.filesystem.read_binary_file(filename) 46 converter = _W3CTestConverter(new_path, filename, reference_support_info, host, convert_test_harness_links )46 converter = _W3CTestConverter(new_path, filename, reference_support_info, host, convert_test_harness_links, webkit_test_runner_options) 47 47 if filename.endswith('.css'): 48 48 return converter.add_webkit_prefix_to_unprefixed_properties_and_values(contents) … … 54 54 55 55 class _W3CTestConverter(HTMLParser): 56 def __init__(self, new_path, filename, reference_support_info, host=Host(), convert_test_harness_links=True ):56 def __init__(self, new_path, filename, reference_support_info, host=Host(), convert_test_harness_links=True, webkit_test_runner_options=''): 57 57 HTMLParser.__init__(self) 58 58 … … 68 68 self.filename = filename 69 69 self.reference_support_info = reference_support_info 70 self.webkit_test_runner_options = webkit_test_runner_options 71 self.has_started = False 70 72 71 73 resources_path = self.path_from_webkit_root('LayoutTests', 'resources') … … 216 218 self.converted_data.append(converted) 217 219 220 def add_webkit_test_runner_options_if_needed(self): 221 if self.has_started: 222 return 223 self.has_started = True 224 if self.webkit_test_runner_options: 225 self.converted_data[-1] = self.converted_data[-1] + self.webkit_test_runner_options 226 218 227 def handle_starttag(self, tag, attrs): 219 228 if tag == 'style': 220 229 self.in_style_tag = True 221 230 self.convert_attributes_if_needed(tag, attrs) 231 self.add_webkit_test_runner_options_if_needed() 222 232 223 233 def handle_endtag(self, tag): … … 245 255 def handle_comment(self, data): 246 256 self.converted_data.extend(['<!-- ', data, ' -->']) 257 self.add_webkit_test_runner_options_if_needed() 247 258 248 259 def handle_decl(self, decl): 249 260 self.converted_data.extend(['<!', decl, '>']) 261 self.add_webkit_test_runner_options_if_needed() 250 262 251 263 def handle_pi(self, data): 252 264 self.converted_data.extend(['<?', data, '>']) 265 self.add_webkit_test_runner_options_if_needed() -
trunk/Tools/Scripts/webkitpy/w3c/test_exporter.py
r240438 r245287 183 183 # FIXME: We can probably try to use --relative git parameter to not do that replacement. 184 184 patch_data = patch_data.replace(WEBKIT_WPT_DIR + '/', '') 185 186 # FIXME: Support stripping of <!-- webkit-test-runner --> comments. 187 self.has_webkit_test_runner_specific_changes = 'webkit-test-runner' in patch_data 188 if self.has_webkit_test_runner_specific_changes: 189 _log.warning("Patch contains webkit-test-runner specific changes, please remove them before creating a PR") 190 return '' 191 185 192 self._filesystem.write_text_file(patch_file, patch_data) 186 193 return patch_file … … 307 314 308 315 def make_pull_request(self): 316 if self.has_webkit_test_runner_specific_changes: 317 _log.error('Cannot create a WPT PR since it contains webkit test runner specific changes') 318 return 319 309 320 if not self._github: 310 321 _log.info('Skipping pull request because OAuth token was not provided. You can open the pull request manually using the branch ' + self._wpt_fork_branch_github_url) -
trunk/Tools/Scripts/webkitpy/w3c/test_importer.py
r233624 r245287 361 361 return self.options.convert_test_harness_links 362 362 363 def _webkit_test_runner_options(self, path): 364 if not(self.filesystem.isfile(path)): 365 return '' 366 367 options_prefix = '<!-- webkit-test-runner' 368 contents = self.filesystem.read_text_file(path).split('\n') 369 if not len(contents): 370 return '' 371 first_line = contents[0] 372 373 return first_line[first_line.index(options_prefix):] if options_prefix in first_line else '' 374 375 def _add_webkit_test_runner_options_to_content(self, content, webkit_test_runner_options): 376 lines = content.split('\n') 377 if not len(lines): 378 return '' 379 lines[0] = lines[0] + webkit_test_runner_options 380 return '\n'.join(lines) 381 382 def _copy_html_file(self, source_filepath, new_filepath): 383 webkit_test_runner_options = self._webkit_test_runner_options(new_filepath) 384 if not webkit_test_runner_options: 385 self.filesystem.copyfile(source_filepath, new_filepath) 386 return 387 388 source_content = self.filesystem.read_text_file(source_filepath) 389 self.filesystem.write_text_file(new_filepath, self._add_webkit_test_runner_options_to_content(source_content, webkit_test_runner_options)) 390 391 def _write_html_template(self, new_filepath): 392 webkit_test_runner_options = self._webkit_test_runner_options(new_filepath) 393 content = '<!-- This file is required for WebKit test infrastructure to run the templated test -->' 394 self.filesystem.write_text_file(new_filepath, content + webkit_test_runner_options) 395 363 396 def write_html_files_for_templated_js_tests(self, orig_filepath, new_filepath): 364 content = '<!-- This file is required for WebKit test infrastructure to run the templated test -->'365 397 if (orig_filepath.endswith('.window.js')): 366 self. filesystem.write_text_file(new_filepath.replace('.window.js', '.window.html'), content)398 self._write_html_template(new_filepath.replace('.window.js', '.window.html')) 367 399 return 368 400 if (orig_filepath.endswith('.worker.js')): 369 self. filesystem.write_text_file(new_filepath.replace('.worker.js', '.worker.html'), content)401 self._write_html_template(new_filepath.replace('.worker.js', '.worker.html')) 370 402 return 371 403 if (orig_filepath.endswith('.any.js')): 372 self. filesystem.write_text_file(new_filepath.replace('.any.js', '.any.html'), content)373 self. filesystem.write_text_file(new_filepath.replace('.any.js', '.any.worker.html'), content)404 self._write_html_template(new_filepath.replace('.any.js', '.any.html')) 405 self._write_html_template(new_filepath.replace('.any.js', '.any.worker.html')) 374 406 return 375 407 … … 450 482 if should_rewrite_files and ('html' in str(mimetype[0]) or 'xml' in str(mimetype[0]) or 'css' in str(mimetype[0])): 451 483 try: 452 converted_file = convert_for_webkit(new_path, filename=orig_filepath, reference_support_info=reference_support_info, host=self.host, convert_test_harness_links=self.should_convert_test_harness_links(subpath) )484 converted_file = convert_for_webkit(new_path, filename=orig_filepath, reference_support_info=reference_support_info, host=self.host, convert_test_harness_links=self.should_convert_test_harness_links(subpath), webkit_test_runner_options=self._webkit_test_runner_options(new_filepath)) 453 485 except: 454 486 _log.warn('Failed converting %s', orig_filepath) … … 475 507 # Some bots dislike empty __init__.py. 476 508 self.write_init_py(new_filepath) 509 elif 'html' in str(mimetype[0]): 510 self._copy_html_file(orig_filepath, new_filepath) 477 511 else: 478 512 self.filesystem.copyfile(orig_filepath, new_filepath) -
trunk/Tools/Scripts/webkitpy/w3c/test_importer_unittest.py
r223281 r245287 305 305 self.assertFalse(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/new-manual.html')) 306 306 self.assertEquals(tests_options, fs.read_text_file('/mock-checkout/LayoutTests/tests-options.json')) 307 308 def test_webkit_test_runner_options(self): 309 FAKE_FILES = { 310 '/mock-checkout/WebKitBuild/w3c-tests/csswg-tests/t/test.html': '<!doctype html><script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>', 311 '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/css/test.html': '<!doctype html>\n<script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>', 312 '/mock-checkout/LayoutTests/w3c/web-platform-tests/css/test.html': '<!-- doctype html --><!-- webkit-test-runner [ dummy ] -->', 313 '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/t/test.html': '<!doctype html><script src="/resources/testharness.js"></script><script src="/resources/testharnessreport.js"></script>', 314 '/mock-checkout/LayoutTests/w3c/web-platform-tests/t/test.html': '<!-- doctype html --><!-- webkit-test-runner [ dummy ] -->', 315 '/mock-checkout/WebKitBuild/w3c-tests/web-platform-tests/t/test.any.js': 'test(() => {}, "empty")', 316 '/mock-checkout/LayoutTests/w3c/web-platform-tests/t/test.any.html': '<!-- This file is required for WebKit test infrastructure to run the templated test --><!-- webkit-test-runner [ dummy ] -->', 317 '/mock-checkout/Source/WebCore/css/CSSProperties.json': '', 318 '/mock-checkout/Source/WebCore/css/CSSValueKeywords.in': '', 319 } 320 FAKE_FILES.update(FAKE_REPOSITORY) 321 322 fs = self.import_downloaded_tests(['--no-fetch', '--import-all', '-d', 'w3c'], FAKE_FILES) 323 324 self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/css/test.html')) 325 self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/test.html')) 326 self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/test.any.html')) 327 self.assertTrue(fs.exists('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/test.any.worker.html')) 328 self.assertTrue('<!-- webkit-test-runner [ dummy ] -->' in fs.read_text_file('/mock-checkout/LayoutTests/w3c/web-platform-tests/css/test.html').split('\n')[0]) 329 self.assertTrue('<!-- webkit-test-runner [ dummy ] -->' in fs.read_text_file('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/test.html').split('\n')[0]) 330 self.assertTrue('<!-- webkit-test-runner [ dummy ] -->' in fs.read_text_file('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/test.any.html').split('\n')[0]) 331 self.assertFalse('<!-- webkit-test-runner [ dummy ] -->' in fs.read_text_file('/mock-checkout/LayoutTests/w3c/web-platform-tests/t/test.any.worker.html').split('\n')[0])
Note: See TracChangeset
for help on using the changeset viewer.