Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/wpt_manifest.py

Issue 2767673002: WPTServe: Run .any.js and .worker.js variations (Closed)
Patch Set: TestExpectations hacky fix Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """WPTManifest is responsible for handling MANIFEST.json. 5 """WPTManifest is responsible for handling MANIFEST.json.
6 6
7 The MANIFEST.json file contains metadata about files in web-platform-tests, 7 The MANIFEST.json file contains metadata about files in web-platform-tests,
8 such as what tests exist, and extra information about each test, including 8 such as what tests exist, and extra information about each test, including
9 test type, options, URLs to use, and reference file paths if applicable. 9 test type, options, URLs to use, and reference file paths if applicable.
10 """ 10 """
11 11
12 import json 12 import json
13 import logging 13 import logging
14 14
15 from webkitpy.common.memoized import memoized
15 from webkitpy.common.webkit_finder import WebKitFinder 16 from webkitpy.common.webkit_finder import WebKitFinder
16 17
17 _log = logging.getLogger(__file__) 18 _log = logging.getLogger(__file__)
18 19
19 20
20 class WPTManifest(object): 21 class WPTManifest(object):
21 22
22 def __init__(self, json_content): 23 def __init__(self, json_content):
23 # TODO(tkent): Create a Manifest object by Manifest.from_json(). 24 # TODO(tkent): Create a Manifest object by Manifest.from_json().
24 # See ../thirdparty/wpt/wpt/tools/manifest/manifest.py. 25 # See ../thirdparty/wpt/wpt/tools/manifest/manifest.py.
(...skipping 12 matching lines...) Expand all
37 """ 38 """
38 items = self.raw_dict['items'] 39 items = self.raw_dict['items']
39 if path_in_wpt in items['manual']: 40 if path_in_wpt in items['manual']:
40 return items['manual'][path_in_wpt] 41 return items['manual'][path_in_wpt]
41 elif path_in_wpt in items['reftest']: 42 elif path_in_wpt in items['reftest']:
42 return items['reftest'][path_in_wpt] 43 return items['reftest'][path_in_wpt]
43 elif path_in_wpt in items['testharness']: 44 elif path_in_wpt in items['testharness']:
44 return items['testharness'][path_in_wpt] 45 return items['testharness'][path_in_wpt]
45 return None 46 return None
46 47
48 @memoized
49 def _urls(self):
50 """Returns a set of the urls for all items in the manifest."""
51 urls = set()
52 if 'items' in self.raw_dict:
53 items = self.raw_dict['items']
54 for category in ('manual', 'reftest', 'testharness'):
55 if category in items:
56 for records in items[category].values():
57 urls.update([item[0] for item in records])
58 return urls
59
47 def is_test_file(self, path_in_wpt): 60 def is_test_file(self, path_in_wpt):
48 return self._items_for_path(path_in_wpt) is not None 61 return self._items_for_path(path_in_wpt) is not None
49 62
63 def is_test_url(self, url):
64 """Check if the passed 'url' is associated with a test
65 in the manifest. The url must be just the pathname,
66 with a leading slash (/)."""
67 if url[0] != '/':
68 raise Exception('Test url missing leading /: %s' % url)
69 return url in self._urls()
70
50 def file_path_to_url_paths(self, path_in_wpt): 71 def file_path_to_url_paths(self, path_in_wpt):
51 manifest_items = self._items_for_path(path_in_wpt) 72 manifest_items = self._items_for_path(path_in_wpt)
52 assert manifest_items is not None 73 assert manifest_items is not None
53 if len(manifest_items) != 1: 74 return [item[0][1:] for item in manifest_items]
54 return []
55 url = manifest_items[0][0]
56 if url[1:] != path_in_wpt:
57 # TODO(tkent): foo.any.js and bar.worker.js should be accessed
58 # as foo.any.html, foo.any.worker, and bar.worker with WPTServe.
59 return []
60 return [path_in_wpt]
61 75
62 @staticmethod 76 @staticmethod
63 def _get_extras_from_item(item): 77 def _get_extras_from_item(item):
64 return item[-1] 78 return item[-1]
65 79
66 def is_slow_test(self, test_name): 80 def is_slow_test(self, test_name):
67 items = self._items_for_path(test_name) 81 items = self._items_for_path(test_name)
68 if not items: 82 if not items:
69 return False 83 return False
70 extras = WPTManifest._get_extras_from_item(items[0]) 84 extras = WPTManifest._get_extras_from_item(items[0])
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 proc = executive.popen(cmd, stdout=executive.PIPE, stderr=executive.PIPE , stdin=executive.PIPE, cwd=finder.webkit_base()) 131 proc = executive.popen(cmd, stdout=executive.PIPE, stderr=executive.PIPE , stdin=executive.PIPE, cwd=finder.webkit_base())
118 out, err = proc.communicate('') 132 out, err = proc.communicate('')
119 if proc.returncode: 133 if proc.returncode:
120 _log.info('# ret> %d', proc.returncode) 134 _log.info('# ret> %d', proc.returncode)
121 if out: 135 if out:
122 _log.info(out) 136 _log.info(out)
123 if err: 137 if err:
124 _log.info(err) 138 _log.info(err)
125 host.exit(proc.returncode) 139 host.exit(proc.returncode)
126 return proc.returncode, out 140 return proc.returncode, out
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698