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

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: Apply review comments 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 for handling MANIFEST.json.
6
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
9 test type, options, URLs to use, and reference file paths if applicable.
10 """
11
12 import json
13 import logging
14
15 from webkitpy.common.webkit_finder import WebKitFinder
16
17 _log = logging.getLogger(__file__)
18
19
20 class WPTManifest(object):
21
22 def __init__(self, json_content):
23 # TODO(tkent): Create a Manifest object by Manifest.from_json().
24 # See ../thirdparty/wpt/wpt/tools/manifest/manifest.py.
25 self.raw_dict = json.loads(json_content)
26
27 def _items_for_path(self, path_in_wpt):
28 """Returns manifest items for the given WPT path, or None if not found.
29
30 The format of a manifest item depends on
31 https://github.com/w3c/wpt-tools/blob/master/manifest/item.py
32 and is assumed to be a list of the format [url, extras],
33 or [url, references, extras] for reftests, or None if not found.
34
35 For most testharness tests, the returned items is expected
36 to look like this:: [["/some/test/path.html", {}]]
37 """
38 items = self.raw_dict['items']
39 if path_in_wpt in items['manual']:
40 return items['manual'][path_in_wpt]
41 elif path_in_wpt in items['reftest']:
42 return items['reftest'][path_in_wpt]
43 elif path_in_wpt in items['testharness']:
44 return items['testharness'][path_in_wpt]
45 return None
46
47 def is_test_file(self, path_in_wpt):
48 return self._items_for_path(path_in_wpt) is not None
49
50 def file_path_to_url_paths(self, path_in_wpt):
51 manifest_items = self._items_for_path(path_in_wpt)
52 assert manifest_items is not None
53 if len(manifest_items) != 1:
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
62 @staticmethod
63 def _get_extras_from_item(item):
64 return item[-1]
65
66 def is_slow_test(self, test_name):
67 items = self._items_for_path(test_name)
68 if not items:
69 return False
70 extras = WPTManifest._get_extras_from_item(items[0])
71 return 'timeout' in extras and extras['timeout'] == 'long'
72
73 def extract_reference_list(self, path_in_wpt):
74 """Extracts reference information of the specified reference test.
75
76 The return value is a list of (match/not-match, reference path in wpt)
77 like:
78 [("==", "foo/bar/baz-match.html"),
79 ("!=", "foo/bar/baz-mismatch.html")]
80 """
81 all_items = self.raw_dict['items']
82 if path_in_wpt not in all_items['reftest']:
83 return []
84 reftest_list = []
85 for item in all_items['reftest'][path_in_wpt]:
86 for ref_path_in_wpt, expectation in item[1]:
87 reftest_list.append((expectation, ref_path_in_wpt))
88 return reftest_list
89
90 @staticmethod
91 def generate_manifest(host, dest_path):
92 """Generates MANIFEST.json on the specified directory."""
93 executive = host.executive
94 finder = WebKitFinder(host.filesystem)
95 cmd = [finder.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thi rdparty', 'wpt', 'wpt', 'manifest'),
96 '--work', '--tests-root', dest_path]
97 _log.debug('Running command: %s', ' '.join(cmd))
98 proc = executive.popen(cmd, stdout=executive.PIPE, stderr=executive.PIPE , stdin=executive.PIPE, cwd=finder.webkit_base())
99 out, err = proc.communicate('')
100 if proc.returncode:
101 _log.info('# ret> %d' % proc.returncode)
102 if out:
103 _log.info(out)
104 if err:
105 _log.info(err)
106 host.exit(proc.returncode)
107 return proc.returncode, out
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