| 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 """ |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 all_items = self.raw_dict['items'] | 81 all_items = self.raw_dict['items'] |
| 82 if path_in_wpt not in all_items['reftest']: | 82 if path_in_wpt not in all_items['reftest']: |
| 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): |
| 92 """Checks whether the manifest exists, and then generates it if necessar
y.""" |
| 93 finder = WebKitFinder(host.filesystem) |
| 94 manifest_path = finder.path_from_webkit_base('LayoutTests', 'external',
'wpt', 'MANIFEST.json') |
| 95 base_manifest_path = finder.path_from_webkit_base('LayoutTests', 'extern
al', 'WPT_BASE_MANIFEST.json') |
| 96 |
| 97 if not host.filesystem.exists(base_manifest_path): |
| 98 _log.error('Manifest base not found at "%s".', base_manifest_path) |
| 99 host.filesystem.write_text_file(base_manifest_path, '{}') |
| 100 |
| 101 if not host.filesystem.exists(manifest_path): |
| 102 _log.debug('Manifest not found, copying from base "%s".', base_manif
est_path) |
| 103 host.filesystem.copyfile(base_manifest_path, manifest_path) |
| 104 |
| 105 wpt_path = manifest_path = finder.path_from_webkit_base('LayoutTests', '
external', 'wpt') |
| 106 WPTManifest.generate_manifest(host, wpt_path) |
| 107 |
| 108 @staticmethod |
| 91 def generate_manifest(host, dest_path): | 109 def generate_manifest(host, dest_path): |
| 92 """Generates MANIFEST.json on the specified directory.""" | 110 """Generates MANIFEST.json on the specified directory.""" |
| 93 executive = host.executive | 111 executive = host.executive |
| 94 finder = WebKitFinder(host.filesystem) | 112 finder = WebKitFinder(host.filesystem) |
| 95 manifest_exec_path = finder.path_from_webkit_base('Tools', 'Scripts', 'w
ebkitpy', 'thirdparty', 'wpt', 'wpt', 'manifest') | 113 manifest_exec_path = finder.path_from_webkit_base('Tools', 'Scripts', 'w
ebkitpy', 'thirdparty', 'wpt', 'wpt', 'manifest') |
| 96 | 114 |
| 97 cmd = ['python', manifest_exec_path, '--work', '--tests-root', dest_path
] | 115 cmd = ['python', manifest_exec_path, '--work', '--tests-root', dest_path
] |
| 98 _log.debug('Running command: %s', ' '.join(cmd)) | 116 _log.debug('Running command: %s', ' '.join(cmd)) |
| 99 proc = executive.popen(cmd, stdout=executive.PIPE, stderr=executive.PIPE
, stdin=executive.PIPE, cwd=finder.webkit_base()) | 117 proc = executive.popen(cmd, stdout=executive.PIPE, stderr=executive.PIPE
, stdin=executive.PIPE, cwd=finder.webkit_base()) |
| 100 out, err = proc.communicate('') | 118 out, err = proc.communicate('') |
| 101 if proc.returncode: | 119 if proc.returncode: |
| 102 _log.info('# ret> %d' % proc.returncode) | 120 _log.info('# ret> %d', proc.returncode) |
| 103 if out: | 121 if out: |
| 104 _log.info(out) | 122 _log.info(out) |
| 105 if err: | 123 if err: |
| 106 _log.info(err) | 124 _log.info(err) |
| 107 host.exit(proc.returncode) | 125 host.exit(proc.returncode) |
| 108 return proc.returncode, out | 126 return proc.returncode, out |
| OLD | NEW |