| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 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 import argparse | 5 import argparse |
| 6 import contextlib | 6 import contextlib |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 return args.func(args) | 63 return args.func(args) |
| 64 | 64 |
| 65 | 65 |
| 66 def run_command(argv, env=None, cwd=None): | 66 def run_command(argv, env=None, cwd=None): |
| 67 print 'Running %r in %r (env: %r)' % (argv, cwd, env) | 67 print 'Running %r in %r (env: %r)' % (argv, cwd, env) |
| 68 rc = subprocess.call(argv, env=env, cwd=cwd) | 68 rc = subprocess.call(argv, env=env, cwd=cwd) |
| 69 print 'Command %r returned exit code %d' % (argv, rc) | 69 print 'Command %r returned exit code %d' % (argv, rc) |
| 70 return rc | 70 return rc |
| 71 | 71 |
| 72 | 72 |
| 73 def run_command_with_output(argv, env=None, cwd=None, stdoutfile=None): |
| 74 print 'Running %r in %r (env: %r)' % (argv, cwd, env) |
| 75 rc = 1 |
| 76 try: |
| 77 output = subprocess.check_output(argv, env=env, cwd=cwd) |
| 78 if stdoutfile: |
| 79 with open(stdoutfile, 'w') as fp: |
| 80 fp.write(output) |
| 81 rc = 0 |
| 82 except Exception: |
| 83 # Exit code remains 1 and we don't write output |
| 84 pass |
| 85 print 'Command %r returned exit code %d' % (argv, rc) |
| 86 return rc |
| 87 |
| 88 |
| 73 def run_runtest(cmd_args, runtest_args): | 89 def run_runtest(cmd_args, runtest_args): |
| 74 if cmd_args.use_src_side_runtest_py: | 90 if cmd_args.use_src_side_runtest_py: |
| 75 cmd = [ | 91 cmd = [ |
| 76 sys.executable, | 92 sys.executable, |
| 77 os.path.join( | 93 os.path.join( |
| 78 cmd_args.paths['checkout'], 'infra', 'scripts', 'runtest_wrapper.py'), | 94 cmd_args.paths['checkout'], 'infra', 'scripts', 'runtest_wrapper.py'), |
| 79 '--', | 95 '--', |
| 80 ] | 96 ] |
| 81 else: | 97 else: |
| 82 cmd = [ | 98 cmd = [ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 [sys.executable, script_to_run] + extra_args) | 179 [sys.executable, script_to_run] + extra_args) |
| 164 | 180 |
| 165 with open(log_file) as f: | 181 with open(log_file) as f: |
| 166 failures = json.load(f) | 182 failures = json.load(f) |
| 167 json.dump({ | 183 json.dump({ |
| 168 'valid': integration_test_res == 0, | 184 'valid': integration_test_res == 0, |
| 169 'failures': failures, | 185 'failures': failures, |
| 170 }, output) | 186 }, output) |
| 171 | 187 |
| 172 return integration_test_res | 188 return integration_test_res |
| OLD | NEW |