Chromium Code Reviews| 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): | 73 def run_command_with_output(argv, env=None, cwd=None, stdoutfile=None): |
|
nednguyen
2017/05/11 00:03:09
This is used in run_gtest_perf_test (https://cs.ch
| |
| 74 print 'Running %r in %r (env: %r)' % (argv, cwd, env) | 74 print 'Running %r in %r (env: %r)' % (argv, cwd, env) |
| 75 rc = 1 | 75 rc = 1 |
| 76 try: | 76 try: |
| 77 output = subprocess.check_output(argv, env=env, cwd=cwd) | 77 output = subprocess.check_output(argv, env=env, cwd=cwd, |
| 78 stderr=subprocess.STDOUT) | |
| 78 if stdoutfile: | 79 if stdoutfile: |
| 79 with open(stdoutfile, 'w') as fp: | 80 with open(stdoutfile, 'w') as fp: |
| 80 fp.write(output) | 81 fp.write(output) |
| 81 rc = 0 | 82 rc = 0 |
| 82 except Exception: | 83 except Exception: |
| 83 # Exit code remains 1 and we don't write output | 84 # Exit code remains 1 and we don't write output |
| 84 pass | 85 pass |
| 85 print 'Command %r returned exit code %d' % (argv, rc) | 86 print 'Command %r returned exit code %d' % (argv, rc) |
| 86 return rc | 87 return rc |
| 87 | 88 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 [sys.executable, script_to_run] + extra_args) | 180 [sys.executable, script_to_run] + extra_args) |
| 180 | 181 |
| 181 with open(log_file) as f: | 182 with open(log_file) as f: |
| 182 failures = json.load(f) | 183 failures = json.load(f) |
| 183 json.dump({ | 184 json.dump({ |
| 184 'valid': integration_test_res == 0, | 185 'valid': integration_test_res == 0, |
| 185 'failures': failures, | 186 'failures': failures, |
| 186 }, output) | 187 }, output) |
| 187 | 188 |
| 188 return integration_test_res | 189 return integration_test_res |
| OLD | NEW |