| OLD | NEW |
| 1 # Copyright 2016 The LUCI Authors. All rights reserved. | 1 # Copyright 2016 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 from __future__ import print_function | 5 from __future__ import print_function |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 def fetch(repo_root, package_spec): | 101 def fetch(repo_root, package_spec): |
| 102 """ | 102 """ |
| 103 Just fetch the recipes to the newly configured version. | 103 Just fetch the recipes to the newly configured version. |
| 104 """ | 104 """ |
| 105 # Use _local_ recipes.py, so that it checks out the pinned recipe engine, | 105 # Use _local_ recipes.py, so that it checks out the pinned recipe engine, |
| 106 # rather than running recipe engine which may be at a different revision | 106 # rather than running recipe engine which may be at a different revision |
| 107 # than the pinned one. | 107 # than the pinned one. |
| 108 args = [ | 108 args = [ |
| 109 sys.executable, | 109 sys.executable, |
| 110 os.path.join(repo_root, package_spec.recipes_path, 'recipes.py'), | 110 os.path.join(repo_root, package_spec.recipes_path, 'recipes.py'), |
| 111 # Invoked recipes.py should not re-bootstrap (to avoid issues on bots). | |
| 112 '--disable-bootstrap', | |
| 113 'fetch', | 111 'fetch', |
| 114 ] | 112 ] |
| 115 subprocess.check_call(args) | 113 subprocess.check_call(args) |
| 116 | 114 |
| 117 | 115 |
| 118 def run_simulation_test(repo_root, package_spec, additional_args=None, | 116 def run_simulation_test(repo_root, package_spec, additional_args=None, |
| 119 allow_fetch=False): | 117 allow_fetch=False): |
| 120 """ | 118 """ |
| 121 Runs recipe simulation test for given package. | 119 Runs recipe simulation test for given package. |
| 122 | 120 |
| 123 Returns a tuple of exit code and output. | 121 Returns a tuple of exit code and output. |
| 124 """ | 122 """ |
| 125 # Use _local_ recipes.py, so that it checks out the pinned recipe engine, | 123 # Use _local_ recipes.py, so that it checks out the pinned recipe engine, |
| 126 # rather than running recipe engine which may be at a different revision | 124 # rather than running recipe engine which may be at a different revision |
| 127 # than the pinned one. | 125 # than the pinned one. |
| 128 args = [ | 126 args = [ |
| 129 sys.executable, | 127 sys.executable, |
| 130 os.path.join(repo_root, package_spec.recipes_path, 'recipes.py'), | 128 os.path.join(repo_root, package_spec.recipes_path, 'recipes.py'), |
| 131 # Invoked recipes.py should not re-bootstrap (to avoid issues on bots). | |
| 132 '--disable-bootstrap', | |
| 133 ] | 129 ] |
| 134 if not allow_fetch: | 130 if not allow_fetch: |
| 135 args.append('--no-fetch') | 131 args.append('--no-fetch') |
| 136 args.append('test') | 132 args.append('test') |
| 137 if additional_args: | 133 if additional_args: |
| 138 args.extend(additional_args) | 134 args.extend(additional_args) |
| 139 p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | 135 p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 140 output, _ = p.communicate() | 136 output, _ = p.communicate() |
| 141 rc = p.returncode | 137 rc = p.returncode |
| 142 return rc, output | 138 return rc, output |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 config_file.write(package_spec.dump()) | 268 config_file.write(package_spec.dump()) |
| 273 run_simulation_test(context.repo_root, package_spec, ['train'], | 269 run_simulation_test(context.repo_root, package_spec, ['train'], |
| 274 allow_fetch=True) | 270 allow_fetch=True) |
| 275 | 271 |
| 276 if args.output_json: | 272 if args.output_json: |
| 277 with open(args.output_json, 'w') as f: | 273 with open(args.output_json, 'w') as f: |
| 278 json.dump( | 274 json.dump( |
| 279 results, f, default=default_json_encode, sort_keys=True, indent=4) | 275 results, f, default=default_json_encode, sort_keys=True, indent=4) |
| 280 | 276 |
| 281 return 0 | 277 return 0 |
| OLD | NEW |