| OLD | NEW |
| 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.webkit_finder import WebKitFinder | 15 from webkitpy.common.path_finder import PathFinder |
| 16 | 16 |
| 17 _log = logging.getLogger(__file__) | 17 _log = logging.getLogger(__file__) |
| 18 | 18 |
| 19 | 19 |
| 20 class WPTManifest(object): | 20 class WPTManifest(object): |
| 21 | 21 |
| 22 def __init__(self, json_content): | 22 def __init__(self, json_content): |
| 23 # TODO(tkent): Create a Manifest object by Manifest.from_json(). | 23 # TODO(tkent): Create a Manifest object by Manifest.from_json(). |
| 24 # See ../thirdparty/wpt/wpt/tools/manifest/manifest.py. | 24 # See ../thirdparty/wpt/wpt/tools/manifest/manifest.py. |
| 25 self.raw_dict = json.loads(json_content) | 25 self.raw_dict = json.loads(json_content) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return [] | 83 return [] |
| 84 reftest_list = [] | 84 reftest_list = [] |
| 85 for item in all_items['reftest'][path_in_wpt]: | 85 for item in all_items['reftest'][path_in_wpt]: |
| 86 for ref_path_in_wpt, expectation in item[1]: | 86 for ref_path_in_wpt, expectation in item[1]: |
| 87 reftest_list.append((expectation, ref_path_in_wpt)) | 87 reftest_list.append((expectation, ref_path_in_wpt)) |
| 88 return reftest_list | 88 return reftest_list |
| 89 | 89 |
| 90 @staticmethod | 90 @staticmethod |
| 91 def ensure_manifest(host): | 91 def ensure_manifest(host): |
| 92 """Checks whether the manifest exists, and then generates it if necessar
y.""" | 92 """Checks whether the manifest exists, and then generates it if necessar
y.""" |
| 93 finder = WebKitFinder(host.filesystem) | 93 finder = PathFinder(host.filesystem) |
| 94 manifest_path = finder.path_from_layout_tests('external', 'wpt', 'MANIFE
ST.json') | 94 manifest_path = finder.path_from_layout_tests('external', 'wpt', 'MANIFE
ST.json') |
| 95 base_manifest_path = finder.path_from_layout_tests('external', 'WPT_BASE
_MANIFEST.json') | 95 base_manifest_path = finder.path_from_layout_tests('external', 'WPT_BASE
_MANIFEST.json') |
| 96 | 96 |
| 97 if not host.filesystem.exists(base_manifest_path): | 97 if not host.filesystem.exists(base_manifest_path): |
| 98 _log.error('Manifest base not found at "%s".', base_manifest_path) | 98 _log.error('Manifest base not found at "%s".', base_manifest_path) |
| 99 host.filesystem.write_text_file(base_manifest_path, '{}') | 99 host.filesystem.write_text_file(base_manifest_path, '{}') |
| 100 | 100 |
| 101 if not host.filesystem.exists(manifest_path): | 101 if not host.filesystem.exists(manifest_path): |
| 102 _log.debug('Manifest not found, copying from base "%s".', base_manif
est_path) | 102 _log.debug('Manifest not found, copying from base "%s".', base_manif
est_path) |
| 103 host.filesystem.copyfile(base_manifest_path, manifest_path) | 103 host.filesystem.copyfile(base_manifest_path, manifest_path) |
| 104 | 104 |
| 105 wpt_path = manifest_path = finder.path_from_layout_tests('external', 'wp
t') | 105 wpt_path = manifest_path = finder.path_from_layout_tests('external', 'wp
t') |
| 106 WPTManifest.generate_manifest(host, wpt_path) | 106 WPTManifest.generate_manifest(host, wpt_path) |
| 107 | 107 |
| 108 # Adding this log line to diagnose https://crbug.com/714503 | 108 # Adding this log line to diagnose https://crbug.com/714503 |
| 109 _log.debug('Manifest generation completed.') | 109 _log.debug('Manifest generation completed.') |
| 110 | 110 |
| 111 @staticmethod | 111 @staticmethod |
| 112 def generate_manifest(host, dest_path): | 112 def generate_manifest(host, dest_path): |
| 113 """Generates MANIFEST.json on the specified directory.""" | 113 """Generates MANIFEST.json on the specified directory.""" |
| 114 executive = host.executive | 114 executive = host.executive |
| 115 finder = WebKitFinder(host.filesystem) | 115 finder = PathFinder(host.filesystem) |
| 116 manifest_exec_path = finder.path_from_tools_scripts('webkitpy', 'thirdpa
rty', 'wpt', 'wpt', 'manifest') | 116 manifest_exec_path = finder.path_from_tools_scripts('webkitpy', 'thirdpa
rty', 'wpt', 'wpt', 'manifest') |
| 117 | 117 |
| 118 cmd = ['python', manifest_exec_path, '--work', '--tests-root', dest_path
] | 118 cmd = ['python', manifest_exec_path, '--work', '--tests-root', dest_path
] |
| 119 _log.debug('Running command: %s', ' '.join(cmd)) | 119 _log.debug('Running command: %s', ' '.join(cmd)) |
| 120 proc = executive.popen(cmd, stdout=executive.PIPE, stderr=executive.PIPE
, stdin=executive.PIPE) | 120 proc = executive.popen(cmd, stdout=executive.PIPE, stderr=executive.PIPE
, stdin=executive.PIPE) |
| 121 out, err = proc.communicate('') | 121 out, err = proc.communicate('') |
| 122 if proc.returncode: | 122 if proc.returncode: |
| 123 _log.info('# ret> %d', proc.returncode) | 123 _log.info('# ret> %d', proc.returncode) |
| 124 if out: | 124 if out: |
| 125 _log.info(out) | 125 _log.info(out) |
| 126 if err: | 126 if err: |
| 127 _log.info(err) | 127 _log.info(err) |
| 128 host.exit(proc.returncode) | 128 host.exit(proc.returncode) |
| 129 return proc.returncode, out | 129 return proc.returncode, out |
| OLD | NEW |