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 os | 6 import os |
7 import Queue | 7 import Queue |
8 import re | 8 import re |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 if hasattr(exception, 'output'): | 126 if hasattr(exception, 'output'): |
127 print exception.output | 127 print exception.output |
128 print str(exception) | 128 print str(exception) |
129 print 72 * "-" | 129 print 72 * "-" |
130 | 130 |
131 | 131 |
132 def _build_command_line(config, args, apptest): | 132 def _build_command_line(config, args, apptest): |
133 """Build the apptest command line. This value isn't executed on Android.""" | 133 """Build the apptest command line. This value isn't executed on Android.""" |
134 paths = Paths(config) | 134 paths = Paths(config) |
135 # On Linux, always run tests with xvfb, but not for --gtest_list_tests. | 135 # On Linux, always run tests with xvfb, but not for --gtest_list_tests. |
136 not_list_tests = not "--gtest_list_tests" in args | 136 use_xvfb = (config.target_os == Config.OS_LINUX and |
137 use_xvfb = config.target_os == Config.OS_LINUX and not_list_tests | 137 not "--gtest_list_tests" in args) |
138 xvfb_prefix = [paths.xvfb, paths.build_dir] if use_xvfb else [] | 138 prefix = [paths.xvfb, paths.build_dir] if use_xvfb else [] |
139 data_dir = ["--use-temporary-user-data-dir"] if not_list_tests else [] | 139 return prefix + [paths.mojo_runner] + args + [apptest] |
140 return xvfb_prefix + [paths.mojo_runner] + data_dir + args + [apptest] | |
141 | 140 |
142 | 141 |
143 # TODO(msw): Determine proper test timeout durations (starting small). | 142 # TODO(msw): Determine proper test timeout durations (starting small). |
144 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): |
145 """Run the test with a timeout; return the output or raise an exception.""" | 144 """Run the test with a timeout; return the output or raise an exception.""" |
146 result = Queue.Queue() | 145 result = Queue.Queue() |
147 thread = threading.Thread(target=_run_test, | 146 thread = threading.Thread(target=_run_test, |
148 args=(config, shell, args, apptest, result)) | 147 args=(config, shell, args, apptest, result)) |
149 thread.start() | 148 thread.start() |
150 process_or_shell = result.get() | 149 process_or_shell = result.get() |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 (r, w) = os.pipe() | 186 (r, w) = os.pipe() |
188 with os.fdopen(r, "r") as rf: | 187 with os.fdopen(r, "r") as rf: |
189 with os.fdopen(w, "w") as wf: | 188 with os.fdopen(w, "w") as wf: |
190 arguments = args + [apptest] | 189 arguments = args + [apptest] |
191 shell.StartActivity('MojoShellActivity', arguments, wf, wf.close) | 190 shell.StartActivity('MojoShellActivity', arguments, wf, wf.close) |
192 output = rf.read() | 191 output = rf.read() |
193 except Exception as e: | 192 except Exception as e: |
194 output = e.output if hasattr(e, 'output') else "" | 193 output = e.output if hasattr(e, 'output') else "" |
195 exception = str(e) | 194 exception = str(e) |
196 result.put((output, exception)) | 195 result.put((output, exception)) |
OLD | NEW |