OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import contextlib | 5 import contextlib |
6 import datetime | 6 import datetime |
7 import json | 7 import json |
8 import os | 8 import os |
9 import pipes | 9 import pipes |
10 import re | 10 import re |
11 import sys | 11 import sys |
| 12 import textwrap |
12 import urllib | 13 import urllib |
13 | 14 |
14 from recipe_engine.types import freeze | 15 from recipe_engine.types import freeze |
15 from recipe_engine import recipe_api | 16 from recipe_engine import recipe_api |
16 | 17 |
17 def _TimestampToIsoFormat(timestamp): | 18 def _TimestampToIsoFormat(timestamp): |
18 return datetime.datetime.utcfromtimestamp(timestamp).strftime('%Y%m%dT%H%M%S') | 19 return datetime.datetime.utcfromtimestamp(timestamp).strftime('%Y%m%dT%H%M%S') |
19 | 20 |
20 | 21 |
21 class AndroidApi(recipe_api.RecipeApi): | 22 class AndroidApi(recipe_api.RecipeApi): |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 131 |
131 # TODO(sivachandra): Manufacture gclient spec such that it contains "src" | 132 # TODO(sivachandra): Manufacture gclient spec such that it contains "src" |
132 # solution + repo_name solution. Then checkout will be automatically | 133 # solution + repo_name solution. Then checkout will be automatically |
133 # correctly set by gclient.checkout | 134 # correctly set by gclient.checkout |
134 self.m.path['checkout'] = self.m.path['slave_build'].join('src') | 135 self.m.path['checkout'] = self.m.path['slave_build'].join('src') |
135 | 136 |
136 self.clean_local_files() | 137 self.clean_local_files() |
137 | 138 |
138 return result | 139 return result |
139 | 140 |
140 def clean_local_files(self): | 141 def clean_local_files(self, clean_pyc_files=True): |
141 target = self.c.BUILD_CONFIG | 142 target = self.c.BUILD_CONFIG |
142 debug_info_dumps = self.m.path['checkout'].join('out', | 143 debug_info_dumps = self.m.path['checkout'].join('out', |
143 target, | 144 target, |
144 'debug_info_dumps') | 145 'debug_info_dumps') |
145 test_logs = self.m.path['checkout'].join('out', target, 'test_logs') | 146 test_logs = self.m.path['checkout'].join('out', target, 'test_logs') |
146 build_product = self.m.path['checkout'].join('out', 'build_product.zip') | 147 build_product = self.m.path['checkout'].join('out', 'build_product.zip') |
147 self.m.python.inline( | 148 python_inline_script = textwrap.dedent(""" |
148 'clean local files', | 149 import shutil, sys, os |
149 """ | 150 shutil.rmtree(sys.argv[1], True) |
150 import shutil, sys, os | 151 shutil.rmtree(sys.argv[2], True) |
151 shutil.rmtree(sys.argv[1], True) | 152 try: |
152 shutil.rmtree(sys.argv[2], True) | 153 os.remove(sys.argv[3]) |
153 try: | 154 except OSError: |
154 os.remove(sys.argv[3]) | 155 pass |
155 except OSError: | 156 """) |
156 pass | 157 if clean_pyc_files: |
| 158 python_inline_script += textwrap.dedent("""\ |
157 for base, _dirs, files in os.walk(sys.argv[4]): | 159 for base, _dirs, files in os.walk(sys.argv[4]): |
158 for f in files: | 160 for f in files: |
159 if f.endswith('.pyc'): | 161 if f.endswith('.pyc'): |
160 os.remove(os.path.join(base, f)) | 162 os.remove(os.path.join(base, f)) |
161 """, | 163 """) |
162 args=[debug_info_dumps, test_logs, build_product, | 164 |
163 self.m.path['checkout']], | 165 self.m.python.inline( |
164 infra_step=True, | 166 'clean local files', |
| 167 python_inline_script, |
| 168 args=[debug_info_dumps, test_logs, build_product, |
| 169 self.m.path['checkout']], |
| 170 infra_step=True, |
165 ) | 171 ) |
166 | 172 |
167 def run_tree_truth(self, additional_repos=None): | 173 def run_tree_truth(self, additional_repos=None): |
168 # TODO(sivachandra): The downstream ToT builder will require | 174 # TODO(sivachandra): The downstream ToT builder will require |
169 # 'Show Revisions' step. | 175 # 'Show Revisions' step. |
170 repos = ['src'] | 176 repos = ['src'] |
171 if additional_repos: | 177 if additional_repos: |
172 repos.extend(additional_repos) | 178 repos.extend(additional_repos) |
173 if self.c.REPO_NAME not in repos and self.c.REPO_NAME: | 179 if self.c.REPO_NAME not in repos and self.c.REPO_NAME: |
174 repos.append(self.c.REPO_NAME) | 180 repos.append(self.c.REPO_NAME) |
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1566 script = self.c.test_runner | 1572 script = self.c.test_runner |
1567 if wrapper_script_suite_name: | 1573 if wrapper_script_suite_name: |
1568 script = self.m.chromium.output_dir.join('bin', 'run_%s' % | 1574 script = self.m.chromium.output_dir.join('bin', 'run_%s' % |
1569 wrapper_script_suite_name) | 1575 wrapper_script_suite_name) |
1570 else: | 1576 else: |
1571 env = kwargs.get('env', {}) | 1577 env = kwargs.get('env', {}) |
1572 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', | 1578 env['CHROMIUM_OUTPUT_DIR'] = env.get('CHROMIUM_OUTPUT_DIR', |
1573 self.m.chromium.output_dir) | 1579 self.m.chromium.output_dir) |
1574 kwargs['env'] = env | 1580 kwargs['env'] = env |
1575 return self.m.python(step_name, script, args, **kwargs) | 1581 return self.m.python(step_name, script, args, **kwargs) |
OLD | NEW |