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

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

Issue 2681733005: webkitpy: Consolidate code for MANIFEST.json into wpt_manifest.py (Closed)
Patch Set: Created 3 years, 10 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/w3c/test_importer.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
(Empty)
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
3 # found in the LICENSE file.
4
5 """WPTManifest is responsible to handle MANIFEST.json.
6 """
qyearsley 2017/02/09 17:29:48 Minor rephrasing: "WPTManifest is responsible for
tkent 2017/02/10 08:05:02 Copied them. Thanks :)
7
8 import json
9 import logging
10
11 from webkitpy.common.webkit_finder import WebKitFinder
12
13 _log = logging.getLogger(__file__)
14
15
16 class WPTManifest(object):
17
18 @staticmethod
19 def generate_manifest(host, dest_path):
20 """Generates MANIFEST.json on the specified directory."""
21 executive = host.executive
22 finder = WebKitFinder(host.filesystem)
23 cmd = [finder.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thi rdparty', 'wpt', 'wpt', 'manifest'),
24 '--work', '--tests-root', dest_path]
25 _log.debug('Running command: %s', ' '.join(cmd))
26 proc = executive.popen(cmd, stdout=executive.PIPE, stderr=executive.PIPE , stdin=executive.PIPE, cwd=finder.webkit_base())
27 out, err = proc.communicate('')
28 if proc.returncode:
29 _log.info('# ret> %d' % proc.returncode)
30 if out:
31 _log.info(out)
32 if err:
33 _log.info(err)
34 host.exit(proc.returncode)
35 return proc.returncode, out
36
37 def __init__(self, json_content):
38 # TODO(tkent): Create a Manifest object by Manifest.from_json().
39 # See ../thirdparty/wpt/wpt/tools/manifest/manifest.py.
40 self.raw_dict = json.loads(json_content)
qyearsley 2017/02/09 17:29:48 Nit: __init__ could be moved to the top of the cla
tkent 2017/02/10 08:05:02 Done.
41
42 def _items_for_path(self, path_in_wpt):
43 """Returns manifest items for the given WPT path, or None if not found.
44
45 The format of a manifest item depends on
46 https://github.com/w3c/wpt-tools/blob/master/manifest/item.py
47 and is assumed to be a list of the format [url, extras],
48 or [url, references, extras] for reftests, or None if not found.
49
50 For most testharness tests, the returned items is expected
51 to look like this:: [["/some/test/path.html", {}]]
52 """
53 items = self.raw_dict['items']
54 if path_in_wpt in items['manual']:
55 return items['manual'][path_in_wpt]
56 elif path_in_wpt in items['reftest']:
57 return items['reftest'][path_in_wpt]
58 elif path_in_wpt in items['testharness']:
59 return items['testharness'][path_in_wpt]
60 return None
61
62 def is_test_file(self, path_in_wpt):
63 return self._items_for_path(path_in_wpt) is not None
64
65 def file_path_to_url_paths(self, path_in_wpt):
66 manifest_items = self._items_for_path(path_in_wpt)
67 assert manifest_items is not None
68 if len(manifest_items) != 1:
69 return []
70 url = manifest_items[0][0]
71 if url[1:] != path_in_wpt:
72 # TODO(tkent): foo.any.js and bar.worker.js should be accessed
73 # as foo.any.html, foo.any.worker, and bar.worker with WPTServe.
74 return []
75 return [path_in_wpt]
76
77 @staticmethod
78 def _get_extras_from_item(item):
79 return item[-1]
80
81 def is_slow_test(self, test_name):
82 items = self._items_for_path(test_name)
83 if not items:
84 return False
85 extras = WPTManifest._get_extras_from_item(items[0])
86 return 'timeout' in extras and extras['timeout'] == 'long'
87
88 def extract_reference_list(self, path_in_wpt):
89 """Extract reference information of the specified reference test.
qyearsley 2017/02/09 17:29:48 Extract -> Extracts
tkent 2017/02/10 08:05:02 Done.
90
91 The return value is a list of (match/not-match, reference path in wpt)
92 like:
93 [("==", "foo/bar/baz-match.html"),
94 ("!=", "foo/bar/baz-mismatch.html")]
95 """
96 all_items = self.raw_dict['items']
97 if path_in_wpt not in all_items['reftest']:
98 return []
99 reftest_list = []
100 for item in all_items['reftest'][path_in_wpt]:
101 for ref_path_in_wpt, expectation in item[1]:
102 reftest_list.append((expectation, ref_path_in_wpt))
103 return reftest_list
OLDNEW
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698