OLD | NEW |
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2014 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 | 5 |
6 """Utility script to launch browser-tests on the Chromoting bot.""" | 6 """Utility script to launch browser-tests on the Chromoting bot.""" |
7 import argparse | 7 import argparse |
8 import subprocess | 8 import subprocess |
9 | 9 |
10 PROD_DIR_ID = '$(PROD_DIR)' | 10 PROD_DIR_ID = '$(PROD_DIR)' |
11 | 11 |
12 | 12 |
13 def LaunchCommand(command): | 13 def LaunchCommand(command): |
14 | 14 |
15 cmd_line = [command] | 15 cmd_line = [command] |
16 try: | 16 try: |
17 results = subprocess.check_output( | 17 p = subprocess.Popen(cmd_line, stdout=subprocess.PIPE, shell=True) |
18 cmd_line, stderr=subprocess.STDOUT, shell=True) | 18 results, err = p.communicate() |
| 19 if 'SUCCESS: all tests passed.' not in results: |
| 20 raise Exception('Test failed\n%s\n%s' % (results, err)) |
19 except subprocess.CalledProcessError, e: | 21 except subprocess.CalledProcessError, e: |
20 raise Exception('Exception %s running command %s' % (e, command)) | 22 raise Exception('Exception %s running command %s' % (e, command)) |
21 else: | 23 else: |
22 print results | 24 print results |
23 finally: | |
24 pass | |
25 | 25 |
26 | 26 |
27 def main(): | 27 def main(): |
28 | 28 |
29 parser = argparse.ArgumentParser() | 29 parser = argparse.ArgumentParser() |
30 parser.add_argument('-f', '--file', | 30 parser.add_argument('-f', '--file', |
31 help='path to file listing commands to be launched.') | 31 help='path to file listing commands to be launched.') |
32 parser.add_argument('-p', '--prod_dir', | 32 parser.add_argument('-p', '--prod_dir', |
33 help='path to folder having product and test binaries.') | 33 help='path to folder having product and test binaries.') |
34 | 34 |
35 args = parser.parse_args() | 35 args = parser.parse_args() |
36 | 36 |
37 with open(args.file) as f: | 37 with open(args.file) as f: |
38 for line in f: | 38 for line in f: |
39 # Replace the PROD_DIR value in the command-line with | 39 # Replace the PROD_DIR value in the command-line with |
40 # the passed in value. | 40 # the passed in value. |
41 line = line.replace(PROD_DIR_ID, args.prod_dir) | 41 line = line.replace(PROD_DIR_ID, args.prod_dir) |
42 LaunchCommand(line) | 42 LaunchCommand(line) |
43 | 43 |
44 if __name__ == '__main__': | 44 if __name__ == '__main__': |
45 main() | 45 main() |
OLD | NEW |