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

Side by Side Diff: scripts/slave/runisolatedtest.py

Issue 101303005: .isolated version 1.2 uses 'path_variables' instead of 'variables'. (Closed) Base URL: https://chromium.googlesource.com/a/chromium/tools/build.git@master
Patch Set: Created 7 years 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 | « no previous file | 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
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """A tool to run a chrome test executable directly, or in isolated mode.""" 6 """A tool to run a chrome test executable directly, or in isolated mode.
7
8 TODO(maruel): This script technically needs to die and be replaced by running
9 all the tests always isolated even when not run on Swarming. This will take a
10 while.
11 """
7 12
8 import json 13 import json
9 import logging 14 import logging
10 import optparse 15 import optparse
11 import os 16 import os
12 import re 17 import re
13 import subprocess 18 import subprocess
14 import sys 19 import sys
15 20
16 from slave import build_directory 21 from slave import build_directory
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 95
91 96
92 def sanitize_isolated_file(isolated_file, build_dir_basename): 97 def sanitize_isolated_file(isolated_file, build_dir_basename):
93 """Crack open .isolated file and fix embedded paths, if necessary. 98 """Crack open .isolated file and fix embedded paths, if necessary.
94 99
95 isolates assume that they can embed the build directory at build time and 100 isolates assume that they can embed the build directory at build time and
96 still used that directory at test time. With a builder/tester setup, this 101 still used that directory at test time. With a builder/tester setup, this
97 isn't generally true, so rewrite the paths in the isolated file. See 102 isn't generally true, so rewrite the paths in the isolated file. See
98 http://crbug.com/311622 for details. This can go away once all bots using 103 http://crbug.com/311622 for details. This can go away once all bots using
99 isolates are using ninja. 104 isolates are using ninja.
105
106 TODO(maruel): Do not forget to delete this code once the Windows incremental
107 builder is switched to ninja.
100 """ 108 """
101 # See the isolates file format description at: 109 # See the isolates file format description at:
102 # https://code.google.com/p/swarming/wiki/IsolatedDesign#.isolated_file_format 110 # https://code.google.com/p/swarming/wiki/IsolatedDesign#.isolated_file_format
103 with open(isolated_file) as f: 111 with open(isolated_file) as f:
104 isolated_data = json.load(f) 112 isolated_data = json.load(f)
105 113
106 # 1. check version 114 # 1. check version
107 if isolated_data['version'].split('.', 1)[0] != '1': 115 if isolated_data['version'].split('.', 1)[0] != '1':
Nico 2013/12/13 20:00:06 Should this be a whitelist of versions then after
M-A Ruel 2013/12/13 20:02:25 .isolated files *are* backward compatibles. It's b
108 logging.error('Unexpected isolate version %s', isolated_data['version']) 116 logging.error('Unexpected isolate version %s', isolated_data['version'])
109 return 1 117 return 1
110 118
111 # 2. fix command, print it 119 # 2. fix command, print it
112 for i in range(len(isolated_data['command'])): 120 for i in range(len(isolated_data['command'])):
113 arg = isolated_data['command'][i] 121 arg = isolated_data['command'][i]
114 isolated_data['command'][i] = sanitize_build_dir(arg, build_dir_basename) 122 isolated_data['command'][i] = sanitize_build_dir(arg, build_dir_basename)
115 123
116 # 3. fix files 124 # 3. fix files
117 sanitized_files = {} 125 sanitized_files = {}
118 for key, value in isolated_data['files'].iteritems(): 126 for key, value in isolated_data['files'].iteritems():
119 # a) fix key 127 # a) fix key
120 key = sanitize_build_dir(key, build_dir_basename) 128 key = sanitize_build_dir(key, build_dir_basename)
121 sanitized_files[key] = value 129 sanitized_files[key] = value
122 # b) fix 'l' entry 130 # b) fix 'l' entry
123 if 'l' in value: 131 if 'l' in value:
124 value['l'] = sanitize_build_dir(value['l'], build_dir_basename) 132 value['l'] = sanitize_build_dir(value['l'], build_dir_basename)
125 isolated_data['files'] = sanitized_files 133 isolated_data['files'] = sanitized_files
126 134
127 # 4. Fix variables->PRODUCT_DIR if necessary (only present in the .state file) 135 # 4. Fix variables->PRODUCT_DIR if necessary (only present in the .state file)
128 variables = isolated_data.get('variables', {}) 136 for name in ('path_variables', 'variables'):
129 if 'PRODUCT_DIR' in variables: 137 variables = isolated_data.get(name, {})
130 variables['PRODUCT_DIR'] = sanitize_build_dir(variables['PRODUCT_DIR'], 138 if 'PRODUCT_DIR' in variables:
131 build_dir_basename) 139 variables['PRODUCT_DIR'] = sanitize_build_dir(variables['PRODUCT_DIR'],
140 build_dir_basename)
132 141
133 # TODO(thakis): fix 'includes' if necessary. 142 # TODO(thakis): fix 'includes' if necessary.
134 143
135 with open(isolated_file, 'w') as f: 144 with open(isolated_file, 'w') as f:
136 json.dump(isolated_data, f) 145 json.dump(isolated_data, f)
137 146
138 147
139 def run_test_isolated(isolate_script, test_exe, original_command): 148 def run_test_isolated(isolate_script, test_exe, original_command):
140 """Runs the test under isolate.py run. 149 """Runs the test under isolate.py run.
141 150
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 isolate_script = os.path.join(options.checkout_dir, 'src', 'tools', 233 isolate_script = os.path.join(options.checkout_dir, 'src', 'tools',
225 'swarm_client', 'isolate.py') 234 'swarm_client', 'isolate.py')
226 return run_test_isolated(isolate_script, test_exe, original_command) 235 return run_test_isolated(isolate_script, test_exe, original_command)
227 else: 236 else:
228 logging.info('Running test normally') 237 logging.info('Running test normally')
229 return run_command(original_command) 238 return run_command(original_command)
230 239
231 240
232 if '__main__' == __name__: 241 if '__main__' == __name__:
233 sys.exit(main(None)) 242 sys.exit(main(None))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698