OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 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 | 6 |
7 """Run the given command through LLVM's coverage tools.""" | 7 """Run the given command through LLVM's coverage tools.""" |
8 | 8 |
9 | 9 |
10 import argparse | 10 import argparse |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 # Parse args. | 155 # Parse args. |
156 parser = argparse.ArgumentParser() | 156 parser = argparse.ArgumentParser() |
157 parser.add_argument('--outResultsFile') | 157 parser.add_argument('--outResultsFile') |
158 parser.add_argument( | 158 parser.add_argument( |
159 '--key', metavar='key_or_value', nargs='+', | 159 '--key', metavar='key_or_value', nargs='+', |
160 help='key/value pairs identifying this bot.') | 160 help='key/value pairs identifying this bot.') |
161 parser.add_argument( | 161 parser.add_argument( |
162 '--properties', metavar='key_or_value', nargs='+', | 162 '--properties', metavar='key_or_value', nargs='+', |
163 help='key/value pairs representing properties of this build.') | 163 help='key/value pairs representing properties of this build.') |
164 args, cmd = parser.parse_known_args() | 164 args, cmd = parser.parse_known_args() |
| 165 |
| 166 # We still need to pass the args we stripped out to DM. |
| 167 cmd.append('--key') |
| 168 cmd.extend(args.key) |
| 169 cmd.append('--properties') |
| 170 cmd.extend(args.properties) |
| 171 |
| 172 # Parse the key and properties for use in the nanobench JSON output. |
165 key = _parse_key_value(args.key) | 173 key = _parse_key_value(args.key) |
166 properties = _parse_key_value(args.properties) | 174 properties = _parse_key_value(args.properties) |
167 | 175 |
168 # Run coverage. | 176 # Run coverage. |
169 results = run_coverage(cmd) | 177 results = run_coverage(cmd) |
170 | 178 |
171 # Write results. | 179 # Write results. |
172 format_results = _nanobench_json(results, properties, key) | 180 format_results = _nanobench_json(results, properties, key) |
173 if args.outResultsFile: | 181 if args.outResultsFile: |
174 with open(args.outResultsFile, 'w') as f: | 182 with open(args.outResultsFile, 'w') as f: |
175 json.dump(format_results, f) | 183 json.dump(format_results, f) |
176 else: | 184 else: |
177 print json.dumps(format_results, indent=4, sort_keys=True) | 185 print json.dumps(format_results, indent=4, sort_keys=True) |
178 | 186 |
179 | 187 |
180 if __name__ == '__main__': | 188 if __name__ == '__main__': |
181 main() | 189 main() |
OLD | NEW |