| 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 subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 print "\n[ FAILED ] Command%s: %s" % (exit_code, " ".join(command_line)) | 123 print "\n[ FAILED ] Command%s: %s" % (exit_code, " ".join(command_line)) |
| 124 print 72 * "-" | 124 print 72 * "-" |
| 125 print error.output if hasattr(error, 'output') else error | 125 print error.output if hasattr(error, 'output') else error |
| 126 print 72 * "-" | 126 print 72 * "-" |
| 127 | 127 |
| 128 | 128 |
| 129 def _build_command_line(config, args, apptest): | 129 def _build_command_line(config, args, apptest): |
| 130 """Build the apptest command line. This value isn't executed on Android.""" | 130 """Build the apptest command line. This value isn't executed on Android.""" |
| 131 paths = Paths(config) | 131 paths = Paths(config) |
| 132 # On Linux, always run tests with xvfb, but not for --gtest_list_tests. | 132 # On Linux, always run tests with xvfb, but not for --gtest_list_tests. |
| 133 use_xvfb = (config.target_os == Config.OS_LINUX and | 133 not_list_tests = not "--gtest_list_tests" in args |
| 134 not "--gtest_list_tests" in args) | 134 use_xvfb = config.target_os == Config.OS_LINUX and not_list_tests |
| 135 prefix = [paths.xvfb, paths.build_dir] if use_xvfb else [] | 135 xvfb_prefix = [paths.xvfb, paths.build_dir] if use_xvfb else [] |
| 136 return prefix + [paths.mojo_runner] + args + [apptest] | 136 data_dir = ["--use-temporary-user-data-dir"] if not_list_tests else [] |
| 137 return xvfb_prefix + [paths.mojo_runner] + data_dir + args + [apptest] |
| 137 | 138 |
| 138 | 139 |
| 139 # TODO(msw): Determine proper test timeout durations (starting small). | 140 # TODO(msw): Determine proper test timeout durations (starting small). |
| 140 def _run_test_with_timeout(config, shell, args, apptest, timeout_in_seconds=10): | 141 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.""" | 142 """Run the given test with a timeout and return the output or an error.""" |
| 142 result = multiprocessing.Queue() | 143 result = multiprocessing.Queue() |
| 143 process = multiprocessing.Process( | 144 process = multiprocessing.Process( |
| 144 target=_run_test, args=(config, shell, args, apptest, result)) | 145 target=_run_test, args=(config, shell, args, apptest, result)) |
| 145 process.start() | 146 process.start() |
| 146 process.join(timeout_in_seconds) | 147 process.join(timeout_in_seconds) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 157 command = _build_command_line(config, args, apptest) | 158 command = _build_command_line(config, args, apptest) |
| 158 result.put(subprocess.check_output(command, stderr=subprocess.STDOUT)) | 159 result.put(subprocess.check_output(command, stderr=subprocess.STDOUT)) |
| 159 return | 160 return |
| 160 | 161 |
| 161 assert shell | 162 assert shell |
| 162 (r, w) = os.pipe() | 163 (r, w) = os.pipe() |
| 163 with os.fdopen(r, "r") as rf: | 164 with os.fdopen(r, "r") as rf: |
| 164 with os.fdopen(w, "w") as wf: | 165 with os.fdopen(w, "w") as wf: |
| 165 shell.StartActivity('MojoShellActivity', args + [apptest], wf, wf.close) | 166 shell.StartActivity('MojoShellActivity', args + [apptest], wf, wf.close) |
| 166 result.put(rf.read()) | 167 result.put(rf.read()) |
| OLD | NEW |