Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """Takes in a test name and retrives all the output that the swarm server | 6 """Takes in a test name and retrives all the output that the swarm server |
| 7 has produced for tests with that name. This is expected to be called as a | 7 has produced for tests with that name. This is expected to be called as a |
| 8 build step. | 8 build step. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import optparse | 11 import optparse |
| 12 import os | 12 import os |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 15 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 16 | 16 |
| 17 from common import find_depot_tools # pylint: disable=W0611 | 17 from common import find_depot_tools # pylint: disable=W0611 |
| 18 from common import gtest_utils | 18 from common import gtest_utils |
| 19 | 19 |
| 20 from slave.swarming import swarming_utils | 20 from slave.swarming import swarming_utils |
| 21 | 21 |
| 22 # From depot tools/ | 22 # From depot_tools/ |
| 23 import fix_encoding | 23 import fix_encoding |
| 24 import subprocess2 | |
| 24 | 25 |
| 25 | 26 |
| 26 NO_OUTPUT_FOUND = ( | 27 NO_OUTPUT_FOUND = ( |
| 27 'No output produced by the test, it may have failed to run.\n' | 28 'No output produced by the test, it may have failed to run.\n' |
| 28 'Showing all the output, including swarm specific output.\n' | 29 'Showing all the output, including swarm specific output.\n' |
| 29 '\n') | 30 '\n') |
| 30 | 31 |
| 31 | 32 |
| 32 def gen_shard_output(result, gtest_parser): | 33 def gen_shard_output(result, gtest_parser): |
| 33 """Returns output for swarm shard.""" | 34 """Returns output for swarm shard.""" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 exit_code = max(exit_code, test_exit_code) | 117 exit_code = max(exit_code, test_exit_code) |
| 117 | 118 |
| 118 output, exit_code = gen_summary_output( | 119 output, exit_code = gen_summary_output( |
| 119 gtest_parser.FailedTests(), | 120 gtest_parser.FailedTests(), |
| 120 exit_code, | 121 exit_code, |
| 121 shards_remaining) | 122 shards_remaining) |
| 122 print output | 123 print output |
| 123 return exit_code | 124 return exit_code |
| 124 | 125 |
| 125 | 126 |
| 127 def v0_1(client, options, test_name): | |
| 128 """Code starting around r218375. | |
| 129 | |
| 130 TODO(maruel): Put exact revision once committe.d | |
| 131 """ | |
| 132 swarming = os.path.join(client, 'swarming.py') | |
| 133 return subprocess2.call( | |
|
M-A Ruel
2013/08/20 20:22:35
In practice, this means https://codereview.chromiu
| |
| 134 [ | |
| 135 sys.executable, | |
| 136 swarming, | |
| 137 'collect', | |
| 138 '--swarming', options.swarming, | |
| 139 test_name, | |
| 140 ]) | |
| 141 | |
| 142 | |
| 126 def determine_version_and_run_handler(client, options, test_name): | 143 def determine_version_and_run_handler(client, options, test_name): |
| 127 """Executes the proper handler based on the code layout and --version | 144 """Executes the proper handler based on the code layout and --version |
| 128 support. | 145 support. |
| 129 """ | 146 """ |
| 130 # TODO(maruel): Determine version when needed. | 147 if os.path.isfile(os.path.join(client, 'swarm_get_results.py')): |
| 131 return v0(client, options, test_name) | 148 # Oh, that's old. |
| 149 return v0(client, options, test_name) | |
| 150 return v0_1(client, options, test_name) | |
| 132 | 151 |
| 133 | 152 |
| 134 def main(): | 153 def main(): |
| 135 """Note: this is solely to run the current master's code and can totally | 154 """Note: this is solely to run the current master's code and can totally |
| 136 differ from the underlying script flags. | 155 differ from the underlying script flags. |
| 137 | 156 |
| 138 To update these flags: | 157 To update these flags: |
| 139 - Update the following code to support both the previous flag and the new | 158 - Update the following code to support both the previous flag and the new |
| 140 flag. | 159 flag. |
| 141 - Change scripts/master/factory/swarm_commands.py to pass the new flag. | 160 - Change scripts/master/factory/swarm_commands.py to pass the new flag. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 156 elif len(args) > 1: | 175 elif len(args) > 1: |
| 157 parser.error('Must specify only one test name.') | 176 parser.error('Must specify only one test name.') |
| 158 options.swarming = options.swarming.rstrip('/') | 177 options.swarming = options.swarming.rstrip('/') |
| 159 | 178 |
| 160 return determine_version_and_run_handler(client, options, args[0]) | 179 return determine_version_and_run_handler(client, options, args[0]) |
| 161 | 180 |
| 162 | 181 |
| 163 if __name__ == '__main__': | 182 if __name__ == '__main__': |
| 164 fix_encoding.fix_encoding() | 183 fix_encoding.fix_encoding() |
| 165 sys.exit(main()) | 184 sys.exit(main()) |
| OLD | NEW |