From 23bfb54ab24e24c82e9b338e090a23eaf25ee115 Mon Sep 17 00:00:00 2001 From: Timur Borkhodoev Date: Thu, 1 Feb 2018 13:37:30 -0500 Subject: [PATCH 1/9] Prints errors if wpt manifest directoriries are not present --- python/tidy/servo_tidy/tidy.py | 43 ++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index e12ae4cdeb3..2521297585f 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -22,10 +22,19 @@ import colorama import toml import voluptuous import yaml - from licenseck import MPL, APACHE, COPYRIGHT, licenses_toml, licenses_dep_toml +topdir = os.path.abspath(os.path.dirname(sys.argv[0])) +wpt = os.path.join(topdir, "tests", "wpt") + + +def wpt_path(*args): + return os.path.join(wpt, *args) + +sys.path.append(wpt_path("web-platform-tests", "tools", "wptrunner", "wptrunner")) +from wptmanifest import parser, node CONFIG_FILE_PATH = os.path.join(".", "servo-tidy.toml") +WPT_MANIFEST_PATH = wpt_path("include.ini") # Default configs config = { @@ -440,6 +449,34 @@ def check_shell(file_name, lines): yield(idx + 1, "variable substitutions should use the full \"${VAR}\" form") +def rec_parse(current_path, current_node): + dirs = [] + for item in current_node.children: + if isinstance(item, node.DataNode): + next_depth = os.path.join(current_path, item.data) + dirs.append(next_depth) + dirs += rec_parse(next_depth, item) + return dirs + + +def check_manifest_dirs(config_file): + if not os.path.exists(config_file): + print("%s manifest file is required but was not found" % config_file) + sys.exit(1) + + # Load configs from include.ini + with open(config_file) as content: + conf_file = content.read() + lines = conf_file.splitlines(True) + + p = parser.parse(lines) + rv = rec_parse(wpt_path("web-platform-tests"), p) + for path in rv: + if not os.path.isdir(path): + print("error {}".format(path)) + return [] + + def check_rust(file_name, lines): if not file_name.endswith(".rs") or \ file_name.endswith(".mako.rs") or \ @@ -1122,6 +1159,8 @@ def run_lint_scripts(only_changed_files=False, progress=True, stylo=False): def scan(only_changed_files=False, progress=True, stylo=False): # check config file for errors config_errors = check_config_file(CONFIG_FILE_PATH) + # check ini directories exist + manifest_errors = check_manifest_dirs(WPT_MANIFEST_PATH) # check directories contain expected files directory_errors = check_directory_files(config['check_ext']) # standard checks @@ -1136,7 +1175,7 @@ def scan(only_changed_files=False, progress=True, stylo=False): lint_errors = run_lint_scripts(only_changed_files, progress, stylo=stylo) # chain all the iterators errors = itertools.chain(config_errors, directory_errors, lint_errors, - file_errors, dep_license_errors) + file_errors, dep_license_errors, manifest_errors) error = None for error in errors: From 3919a7f4fd42dbf7f8d5aaf71dae1e74110de857 Mon Sep 17 00:00:00 2001 From: Timur Borkhodoev Date: Thu, 1 Feb 2018 13:57:17 -0500 Subject: [PATCH 2/9] Add proper formatting and ignore _mozilla --- python/tidy/servo_tidy/tidy.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index 2521297585f..5a050d11f4a 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -459,7 +459,7 @@ def rec_parse(current_path, current_node): return dirs -def check_manifest_dirs(config_file): +def check_manifest_dirs(config_file, print_text=True): if not os.path.exists(config_file): print("%s manifest file is required but was not found" % config_file) sys.exit(1) @@ -469,12 +469,16 @@ def check_manifest_dirs(config_file): conf_file = content.read() lines = conf_file.splitlines(True) + if print_text: + print '\rChecking the wpt manifest file...' + p = parser.parse(lines) rv = rec_parse(wpt_path("web-platform-tests"), p) - for path in rv: + for idx, path in enumerate(rv): + if path.endswith("_mozilla"): + continue if not os.path.isdir(path): - print("error {}".format(path)) - return [] + yield(config_file, idx + 1, "Path in manifest was not found: {}".format(path)) def check_rust(file_name, lines): @@ -1174,8 +1178,8 @@ def scan(only_changed_files=False, progress=True, stylo=False): # other lint checks lint_errors = run_lint_scripts(only_changed_files, progress, stylo=stylo) # chain all the iterators - errors = itertools.chain(config_errors, directory_errors, lint_errors, - file_errors, dep_license_errors, manifest_errors) + errors = itertools.chain(config_errors, manifest_errors, directory_errors, lint_errors, + file_errors, dep_license_errors) error = None for error in errors: From 41bf86631ba682d277baa5201d799f5ad3b147e1 Mon Sep 17 00:00:00 2001 From: Timur Borkhodoev Date: Thu, 1 Feb 2018 14:29:46 -0500 Subject: [PATCH 3/9] Modify(remove, add) tests in include.ini --- tests/wpt/include.ini | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/tests/wpt/include.ini b/tests/wpt/include.ini index 2b197be5984..b7216b1ff20 100644 --- a/tests/wpt/include.ini +++ b/tests/wpt/include.ini @@ -3,8 +3,6 @@ skip: true skip: false [2dcontext] skip: false -[animation-timing] - skip: false [cors] skip: false [css] @@ -53,12 +51,6 @@ skip: true skip: false [selectors] skip: false -[cssom] - skip: false -[cssom-view] - skip: false -[css-values] - skip: false [custom-elements] skip: false [dom] @@ -87,24 +79,16 @@ skip: true skip: true [submission] skip: true - [Opera] - skip: true - [script_scheduling] - skip: false [performance-timeline] skip: false [quirks] skip: false [referrer-policy] skip: false -[selectors] - skip: false [subresource-integrity] skip: false [touch-events] skip: false -[typedarrays] - skip: false [uievents] skip: false [url] @@ -121,5 +105,5 @@ skip: true skip: false [workers] skip: false -[XMLHttpRequest] +[xhr] skip: false From bcb4bd2f3013ef8c415cf0f69143347a0cc6f78b Mon Sep 17 00:00:00 2001 From: Timur Borkhodoev Date: Thu, 1 Feb 2018 15:57:11 -0500 Subject: [PATCH 4/9] Add self-test and modify tidy to accomodate the test --- python/tidy/servo_tidy/tidy.py | 4 ++-- python/tidy/servo_tidy_tests/test_tidy.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index 5a050d11f4a..fa3a610a41d 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -461,8 +461,8 @@ def rec_parse(current_path, current_node): def check_manifest_dirs(config_file, print_text=True): if not os.path.exists(config_file): - print("%s manifest file is required but was not found" % config_file) - sys.exit(1) + yield(config_file, 0, "%s manifest file is required but was not found" % config_file) + return # Load configs from include.ini with open(config_file) as content: diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py index 432d5c1117e..1c4a055a665 100644 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ b/python/tidy/servo_tidy_tests/test_tidy.py @@ -33,6 +33,11 @@ class CheckTidiness(unittest.TestCase): self.assertEqual("ignored directory './fake/dir' doesn't exist", errors.next()[2]) self.assertNoMoreErrors(errors) + def test_wpt_manifest_checks(self): + wrong_path = "/wrong/path.ini" + errors = tidy.check_manifest_dirs(wrong_path) + self.assertEqual("%s manifest file is required but was not found" % wrong_path, errors.next()[2]) + def test_directory_checks(self): dirs = { os.path.join(base_path, "dir_check/webidl_plus"): ['webidl', 'test'], From 06e439ef40a8f59c6172b2dcac8f452431a8b845 Mon Sep 17 00:00:00 2001 From: Timur Borkhodoev Date: Fri, 2 Feb 2018 14:48:43 -0500 Subject: [PATCH 5/9] Add correct file test for manifest test --- .../servo_tidy_tests/manifest-include.ini | 109 ++++++++++++++++++ python/tidy/servo_tidy_tests/test_tidy.py | 7 +- 2 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 python/tidy/servo_tidy_tests/manifest-include.ini diff --git a/python/tidy/servo_tidy_tests/manifest-include.ini b/python/tidy/servo_tidy_tests/manifest-include.ini new file mode 100644 index 00000000000..b7216b1ff20 --- /dev/null +++ b/python/tidy/servo_tidy_tests/manifest-include.ini @@ -0,0 +1,109 @@ +skip: true +[_mozilla] + skip: false +[2dcontext] + skip: false +[cors] + skip: false +[css] + skip: true + [compositing] + skip: false + [CSS2] + skip: false + [css-animations] + skip: false + [css-backgrounds] + skip: false + [css-color] + skip: false + [css-conditional] + skip: false + [css-flexbox] + skip: false + [css-images] + skip: false + [css-style-attr] + skip: false + [css-text] + skip: false + [css-text-decor] + skip: false + [css-transforms] + skip: false + [css-transitions] + skip: false + [css-ui] + skip: false + [css-values] + skip: false + [css-variables] + skip: false + [cssom] + skip: false + [cssom-view] + skip: false + [filter-effects] + skip: false + [geometry] + skip: false + [mediaqueries] + skip: false + [selectors] + skip: false +[custom-elements] + skip: false +[dom] + skip: false +[domparsing] + skip: false +[encoding] + skip: false +[eventsource] + skip: false +[fetch] + skip: false +[FileAPI] + skip: false +[fullscreen] + skip: false +[hr-time] + skip: false +[html] + skip: false +[js] + skip: false +[navigation-timing] + skip: false +[old-tests] + skip: true + [submission] + skip: true +[performance-timeline] + skip: false +[quirks] + skip: false +[referrer-policy] + skip: false +[subresource-integrity] + skip: false +[touch-events] + skip: false +[uievents] + skip: false +[url] + skip: false +[WebCryptoAPI] + skip: false +[webgl] + skip: false +[WebIDL] + skip: false +[websockets] + skip: false +[webstorage] + skip: false +[workers] + skip: false +[xhr] + skip: false diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py index 1c4a055a665..e9e2ffcfdd1 100644 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ b/python/tidy/servo_tidy_tests/test_tidy.py @@ -33,10 +33,13 @@ class CheckTidiness(unittest.TestCase): self.assertEqual("ignored directory './fake/dir' doesn't exist", errors.next()[2]) self.assertNoMoreErrors(errors) - def test_wpt_manifest_checks(self): + def test_non_existing_wpt_manifest_checks(self): wrong_path = "/wrong/path.ini" - errors = tidy.check_manifest_dirs(wrong_path) + errors = tidy.check_manifest_dirs(wrong_path, print_text=False) self.assertEqual("%s manifest file is required but was not found" % wrong_path, errors.next()[2]) + self.assertNoMoreErrors(errors) + errors = tidy.check_manifest_dirs(os.path.join(base_path, 'manifest-include.ini'), print_text=False) + self.assertNoMoreErrors(errors) def test_directory_checks(self): dirs = { From c351b526f6505ec3237038776696ca3c22ec9d87 Mon Sep 17 00:00:00 2001 From: Timur Borkhodoev Date: Fri, 2 Feb 2018 15:34:08 -0500 Subject: [PATCH 6/9] Add test that actually tests the test --- .../servo_tidy_tests/manifest-include.ini | 106 +----------------- python/tidy/servo_tidy_tests/test_tidy.py | 1 + 2 files changed, 2 insertions(+), 105 deletions(-) diff --git a/python/tidy/servo_tidy_tests/manifest-include.ini b/python/tidy/servo_tidy_tests/manifest-include.ini index b7216b1ff20..ade00f2fa31 100644 --- a/python/tidy/servo_tidy_tests/manifest-include.ini +++ b/python/tidy/servo_tidy_tests/manifest-include.ini @@ -1,109 +1,5 @@ skip: true -[_mozilla] - skip: false -[2dcontext] - skip: false -[cors] - skip: false -[css] - skip: true - [compositing] - skip: false - [CSS2] - skip: false - [css-animations] - skip: false - [css-backgrounds] - skip: false - [css-color] - skip: false - [css-conditional] - skip: false - [css-flexbox] - skip: false - [css-images] - skip: false - [css-style-attr] - skip: false - [css-text] - skip: false - [css-text-decor] - skip: false - [css-transforms] - skip: false - [css-transitions] - skip: false - [css-ui] - skip: false - [css-values] - skip: false - [css-variables] - skip: false - [cssom] - skip: false - [cssom-view] - skip: false - [filter-effects] - skip: false - [geometry] - skip: false - [mediaqueries] - skip: false - [selectors] - skip: false -[custom-elements] - skip: false -[dom] - skip: false -[domparsing] - skip: false -[encoding] - skip: false -[eventsource] - skip: false -[fetch] - skip: false -[FileAPI] - skip: false -[fullscreen] - skip: false -[hr-time] - skip: false [html] skip: false -[js] - skip: false -[navigation-timing] - skip: false -[old-tests] - skip: true - [submission] - skip: true -[performance-timeline] - skip: false -[quirks] - skip: false -[referrer-policy] - skip: false -[subresource-integrity] - skip: false -[touch-events] - skip: false -[uievents] - skip: false -[url] - skip: false -[WebCryptoAPI] - skip: false -[webgl] - skip: false -[WebIDL] - skip: false -[websockets] - skip: false -[webstorage] - skip: false -[workers] - skip: false -[xhr] +[never_going_to_exist] skip: false diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py index e9e2ffcfdd1..dbc3f9d4f8b 100644 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ b/python/tidy/servo_tidy_tests/test_tidy.py @@ -39,6 +39,7 @@ class CheckTidiness(unittest.TestCase): self.assertEqual("%s manifest file is required but was not found" % wrong_path, errors.next()[2]) self.assertNoMoreErrors(errors) errors = tidy.check_manifest_dirs(os.path.join(base_path, 'manifest-include.ini'), print_text=False) + self.assertTrue(errors.next()[2].endswith("never_going_to_exist")) self.assertNoMoreErrors(errors) def test_directory_checks(self): From 515300a20c989cf7000f5c40e9f8b00b72dd472c Mon Sep 17 00:00:00 2001 From: Timur Borkhodoev Date: Fri, 2 Feb 2018 15:39:59 -0500 Subject: [PATCH 7/9] Change bad namings --- python/tidy/servo_tidy/tidy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index fa3a610a41d..56e466760e5 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -449,9 +449,9 @@ def check_shell(file_name, lines): yield(idx + 1, "variable substitutions should use the full \"${VAR}\" form") -def rec_parse(current_path, current_node): +def rec_parse(current_path, root_node): dirs = [] - for item in current_node.children: + for item in root_node.children: if isinstance(item, node.DataNode): next_depth = os.path.join(current_path, item.data) dirs.append(next_depth) @@ -473,8 +473,8 @@ def check_manifest_dirs(config_file, print_text=True): print '\rChecking the wpt manifest file...' p = parser.parse(lines) - rv = rec_parse(wpt_path("web-platform-tests"), p) - for idx, path in enumerate(rv): + paths = rec_parse(wpt_path("web-platform-tests"), p) + for idx, path in enumerate(paths): if path.endswith("_mozilla"): continue if not os.path.isdir(path): From 607306af91facc3625c34c8d566a35ecfc5149ec Mon Sep 17 00:00:00 2001 From: Timur Borkhodoev Date: Fri, 2 Feb 2018 17:37:19 -0500 Subject: [PATCH 8/9] Add update-wpt generated ini --- .../metadata/xhr/event-upload-progress-crossorigin.htm.ini | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/wpt/metadata/xhr/event-upload-progress-crossorigin.htm.ini b/tests/wpt/metadata/xhr/event-upload-progress-crossorigin.htm.ini index 0947bf1513a..68c155d21e0 100644 --- a/tests/wpt/metadata/xhr/event-upload-progress-crossorigin.htm.ini +++ b/tests/wpt/metadata/xhr/event-upload-progress-crossorigin.htm.ini @@ -6,3 +6,9 @@ [Upload events registered too late (resources/redirect.py?code=307&location=http://www1.web-platform.test:8000/XMLHttpRequest/resources/corsenabled.py)] expected: FAIL + [Upload events registered too late (http://www1.web-platform.test:8000/xhr/resources/corsenabled.py)] + expected: FAIL + + [Upload events registered too late (resources/redirect.py?code=307&location=http://www1.web-platform.test:8000/xhr/resources/corsenabled.py)] + expected: FAIL + From 1027644cb6b9ae9aa580531c0d85a33936cda1b6 Mon Sep 17 00:00:00 2001 From: Timur Borkhodoev Date: Sat, 3 Feb 2018 15:52:26 -0500 Subject: [PATCH 9/9] Remove a expected fail test --- tests/wpt/metadata/xhr/responsexml-document-properties.htm.ini | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/wpt/metadata/xhr/responsexml-document-properties.htm.ini b/tests/wpt/metadata/xhr/responsexml-document-properties.htm.ini index 2d5b2b753d5..841155cd200 100644 --- a/tests/wpt/metadata/xhr/responsexml-document-properties.htm.ini +++ b/tests/wpt/metadata/xhr/responsexml-document-properties.htm.ini @@ -6,9 +6,6 @@ [readyState] expected: FAIL - [body] - expected: FAIL - [images] expected: FAIL