Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: mojo/tools/mopy/gtest.py

Issue 1179413010: mandoline filesystem: Save cookie data to the mojo:filesystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sqlite-fs
Patch Set: Have mojo_runner responsible for handling the temporary directory. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
msw 2015/06/24 23:00:35 nit: remove
9 import subprocess 10 import subprocess
10 import sys 11 import sys
12 import tempfile
msw 2015/06/24 23:00:35 nit: remove
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 print "\n[ FAILED ] Command%s: %s" % (exit_code, " ".join(command_line)) 125 print "\n[ FAILED ] Command%s: %s" % (exit_code, " ".join(command_line))
124 print 72 * "-" 126 print 72 * "-"
125 print error.output if hasattr(error, 'output') else error 127 print error.output if hasattr(error, 'output') else error
126 print 72 * "-" 128 print 72 * "-"
127 129
128 130
129 def _build_command_line(config, args, apptest): 131 def _build_command_line(config, args, apptest):
130 """Build the apptest command line. This value isn't executed on Android.""" 132 """Build the apptest command line. This value isn't executed on Android."""
131 paths = Paths(config) 133 paths = Paths(config)
132 # On Linux, always run tests with xvfb, but not for --gtest_list_tests. 134 # On Linux, always run tests with xvfb, but not for --gtest_list_tests.
133 use_xvfb = (config.target_os == Config.OS_LINUX and 135 not_list_tests = not "--gtest_list_tests" in args
134 not "--gtest_list_tests" in args) 136 use_xvfb = config.target_os == Config.OS_LINUX and not_list_tests
135 prefix = [paths.xvfb, paths.build_dir] if use_xvfb else [] 137 xvfb_prefix = [paths.xvfb, paths.build_dir] if use_xvfb else []
136 return prefix + [paths.mojo_runner] + args + [apptest] 138 data_dir = ["--use-temporary-user-data-dir"] if not_list_tests else []
139 return xvfb_prefix + [paths.mojo_runner] + data_dir + args + [apptest]
137 140
138 141
139 # TODO(msw): Determine proper test timeout durations (starting small). 142 # TODO(msw): Determine proper test timeout durations (starting small).
140 def _run_test_with_timeout(config, shell, args, apptest, timeout_in_seconds=10): 143 def _run_test_with_timeout(config, shell, args, apptest, timeout_in_seconds=10):
141 """Run the given test with a timeout and return the output or an error.""" 144 """Run the given test with a timeout and return the output or an error."""
142 result = multiprocessing.Queue() 145 result = multiprocessing.Queue()
143 process = multiprocessing.Process( 146 process = multiprocessing.Process(
144 target=_run_test, args=(config, shell, args, apptest, result)) 147 target=_run_test, args=(config, shell, args, apptest, result))
145 process.start() 148 process.start()
146 process.join(timeout_in_seconds) 149 process.join(timeout_in_seconds)
(...skipping 10 matching lines...) Expand all
157 command = _build_command_line(config, args, apptest) 160 command = _build_command_line(config, args, apptest)
158 result.put(subprocess.check_output(command, stderr=subprocess.STDOUT)) 161 result.put(subprocess.check_output(command, stderr=subprocess.STDOUT))
159 return 162 return
160 163
161 assert shell 164 assert shell
162 (r, w) = os.pipe() 165 (r, w) = os.pipe()
163 with os.fdopen(r, "r") as rf: 166 with os.fdopen(r, "r") as rf:
164 with os.fdopen(w, "w") as wf: 167 with os.fdopen(w, "w") as wf:
165 shell.StartActivity('MojoShellActivity', args + [apptest], wf, wf.close) 168 shell.StartActivity('MojoShellActivity', args + [apptest], wf, wf.close)
166 result.put(rf.read()) 169 result.put(rf.read())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698