diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-17 13:57:45 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-07-19 13:44:40 +0000 |
commit | 6ec7b8da05d21a3878bd21c691b41e675d74bb1c (patch) | |
tree | b87f250bc19413750b9bb9cdbf2da20ef5014820 /chromium/testing/scripts/common.py | |
parent | ec02ee4181c49b61fce1c8fb99292dbb8139cc90 (diff) | |
download | qtwebengine-chromium-6ec7b8da05d21a3878bd21c691b41e675d74bb1c.tar.gz |
BASELINE: Update Chromium to 60.0.3112.70
Change-Id: I9911c2280a014d4632f254857876a395d4baed2d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/testing/scripts/common.py')
-rw-r--r-- | chromium/testing/scripts/common.py | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/chromium/testing/scripts/common.py b/chromium/testing/scripts/common.py index f3407767f3d..6454aff3888 100644 --- a/chromium/testing/scripts/common.py +++ b/chromium/testing/scripts/common.py @@ -4,11 +4,14 @@ import argparse import contextlib +import io import json import os +import logging import subprocess import sys import tempfile +import time SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -70,20 +73,22 @@ def run_command(argv, env=None, cwd=None): return rc -def run_command_with_output(argv, env=None, cwd=None, stdoutfile=None): +def run_command_with_output(argv, stdoutfile, env=None, cwd=None): + """ Run command and stream its stdout/stderr to the console & |stdoutfile|. + """ print 'Running %r in %r (env: %r)' % (argv, cwd, env) - rc = 1 - try: - output = subprocess.check_output(argv, env=env, cwd=cwd) - if stdoutfile: - with open(stdoutfile, 'w') as fp: - fp.write(output) - rc = 0 - except Exception: - # Exit code remains 1 and we don't write output - pass - print 'Command %r returned exit code %d' % (argv, rc) - return rc + assert stdoutfile + with io.open(stdoutfile, 'w') as writer, io.open(stdoutfile, 'r', 1) as \ + reader: + process = subprocess.Popen(argv, env=env, cwd=cwd, stdout=writer, + stderr=subprocess.STDOUT) + while process.poll() is None: + sys.stdout.write(reader.read()) + time.sleep(0.1) + # Read the remaining + sys.stdout.write(reader.read()) + print 'Command %r returned exit code %d' % (argv, process.returncode) + return process.returncode def run_runtest(cmd_args, runtest_args): |