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

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

Issue 1144673003: Fix and cleanup Mojo and Mandoline python scripts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments. Created 5 years, 7 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
« no previous file with comments | « mojo/tools/mopy/paths.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 subprocess 7 import subprocess
8 import time 8 import time
9 9
10 from mopy.config import Config 10 from mopy.config import Config
11 from mopy.paths import Paths 11 from mopy.paths import Paths
12 from mopy.print_process_error import print_process_error 12 from mopy.print_process_error import print_process_error
13 13
14 14
15 _logger = logging.getLogger() 15 _logger = logging.getLogger()
16 16
17 17
18 def build_shell_arguments(shell_args, apps_and_args=None): 18 def build_shell_arguments(shell_args, apps_and_args=None):
19 """Build the list of arguments for the shell. |shell_args| are the base 19 """Build the list of arguments for the shell. |shell_args| are the base
20 arguments, |apps_and_args| is a dictionary that associates each application to 20 arguments, |apps_and_args| is a dictionary that associates each application to
21 its specific arguments|. Each app included will be run by the shell. 21 its specific arguments|. Each app included will be run by the shell.
22 """ 22 """
23 result = shell_args[:] 23 result = shell_args[:]
24 if apps_and_args: 24 if apps_and_args:
25 # TODO(msw): Mojo's script uses --args-for; Chromium lacks support for that.
26 for app_and_args in apps_and_args.items(): 25 for app_and_args in apps_and_args.items():
27 result += app_and_args[1] 26 result += app_and_args[1]
28 result += apps_and_args.keys() 27 result += apps_and_args.keys()
29 return result 28 return result
30 29
31 30
32 def get_shell_executable(config): 31 def get_shell_executable(config):
33 paths = Paths(config=config) 32 paths = Paths(config)
34 if config.target_os == Config.OS_ANDROID: 33 if config.target_os == Config.OS_ANDROID:
35 return os.path.join(paths.src_root, "mojo", "tools", 34 return os.path.join(paths.src_root, "mojo", "tools",
36 "android_mojo_shell.py") 35 "android_mojo_shell.py")
37 else: 36 else:
38 return paths.mojo_shell_path 37 return paths.mojo_runner
39 38
40 39
41 def build_command_line(config, shell_args, apps_and_args): 40 def build_command_line(config, shell_args, apps_and_args):
42 executable = get_shell_executable(config) 41 executable = get_shell_executable(config)
43 return "%s %s" % (executable, " ".join(["%r" % x for x in 42 return "%s %s" % (executable, " ".join(["%r" % x for x in
44 build_shell_arguments( 43 build_shell_arguments(
45 shell_args, apps_and_args)])) 44 shell_args, apps_and_args)]))
46 45
47 46
48 def run_test_android(shell, shell_args, apps_and_args): 47 def run_test_android(shell, shell_args, apps_and_args):
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 85
87 def try_run_test(config, shell, shell_args, apps_and_args): 86 def try_run_test(config, shell, shell_args, apps_and_args):
88 """Returns the output of a command line or an empty string on error.""" 87 """Returns the output of a command line or an empty string on error."""
89 command_line = build_command_line(config, shell_args, apps_and_args) 88 command_line = build_command_line(config, shell_args, apps_and_args)
90 _logger.debug("Running command line: %s" % command_line) 89 _logger.debug("Running command line: %s" % command_line)
91 try: 90 try:
92 return run_test(config, shell, shell_args, apps_and_args) 91 return run_test(config, shell, shell_args, apps_and_args)
93 except Exception as e: 92 except Exception as e:
94 print_process_error(command_line, e) 93 print_process_error(command_line, e)
95 return None 94 return None
OLDNEW
« no previous file with comments | « mojo/tools/mopy/paths.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698