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 logging | 5 import logging |
6 import multiprocessing | 6 import multiprocessing |
7 import os | 7 import os |
8 import re | 8 import re |
9 import shutil | |
9 import subprocess | 10 import subprocess |
10 import sys | 11 import sys |
12 import tempfile | |
11 import time | 13 import time |
12 | 14 |
13 from mopy.config import Config | 15 from mopy.config import Config |
14 from mopy.paths import Paths | 16 from mopy.paths import Paths |
15 | 17 |
16 | 18 |
17 def set_color(): | 19 def set_color(): |
18 """Run gtests with color on TTY, unless its environment variable is set.""" | 20 """Run gtests with color on TTY, unless its environment variable is set.""" |
19 if sys.stdout.isatty() and "GTEST_COLOR" not in os.environ: | 21 if sys.stdout.isatty() and "GTEST_COLOR" not in os.environ: |
20 logging.getLogger().debug("Setting GTEST_COLOR=yes") | 22 logging.getLogger().debug("Setting GTEST_COLOR=yes") |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 if process.is_alive(): | 149 if process.is_alive(): |
148 process.terminate() | 150 process.terminate() |
149 process.join() | 151 process.join() |
150 return "Error: Test timeout after %s seconds" % timeout_in_seconds | 152 return "Error: Test timeout after %s seconds" % timeout_in_seconds |
151 return result.get() | 153 return result.get() |
152 | 154 |
153 | 155 |
154 def _run_test(config, shell, args, apptest, result): | 156 def _run_test(config, shell, args, apptest, result): |
155 """Run the given test and puts the output in |result|.""" | 157 """Run the given test and puts the output in |result|.""" |
156 if (config.target_os != Config.OS_ANDROID): | 158 if (config.target_os != Config.OS_ANDROID): |
159 temp_dir = tempfile.mkdtemp() | |
msw
2015/06/24 00:14:40
Avoid making the temp dir and appending the argume
Elliot Glaysher
2015/06/24 22:22:41
I've changed the entire approach here. I set a --u
| |
157 command = _build_command_line(config, args, apptest) | 160 command = _build_command_line(config, args, apptest) |
161 command += ['--user-data-dir=%s' % temp_dir] | |
msw
2015/06/24 00:14:40
Hmm, this argument won't appear in the logs when _
| |
158 result.put(subprocess.check_output(command, stderr=subprocess.STDOUT)) | 162 result.put(subprocess.check_output(command, stderr=subprocess.STDOUT)) |
163 shutil.rmtree(temp_dir) | |
159 return | 164 return |
160 | 165 |
161 assert shell | 166 assert shell |
162 (r, w) = os.pipe() | 167 (r, w) = os.pipe() |
163 with os.fdopen(r, "r") as rf: | 168 with os.fdopen(r, "r") as rf: |
164 with os.fdopen(w, "w") as wf: | 169 with os.fdopen(w, "w") as wf: |
165 shell.StartActivity('MojoShellActivity', args + [apptest], wf, wf.close) | 170 shell.StartActivity('MojoShellActivity', args + [apptest], wf, wf.close) |
msw
2015/06/24 00:14:40
I guess we'll want a shell.mkdtemp and shell.rmtre
| |
166 result.put(rf.read()) | 171 result.put(rf.read()) |
OLD | NEW |