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

Side by Side Diff: mojo/devtools/common/pylib/apptest.py

Issue 1128153002: Rename the devtools library: pylib -> devtoolslib. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Address offline comments/ devtools_lib -> devtoolslib. 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/devtools/common/pylib/android_shell.py ('k') | mojo/devtools/common/pylib/apptest_dart.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """Apptest is a Mojo application that interacts with another Mojo application
6 and verifies assumptions about behavior of the app being tested.
7 """
8
9 import logging
10 import time
11
12
13 _logger = logging.getLogger()
14
15
16 def _build_shell_arguments(shell_args, apptest_url, apptest_args):
17 """Builds the list of arguments for the shell.
18
19 Args:
20 shell_args: List of arguments for the shell run.
21 apptest_url: Url of the apptest app to run.
22 apptest_args: Parameters to be passed to the apptest app.
23
24 Returns:
25 Single list of shell arguments.
26 """
27 result = list(shell_args)
28 if apptest_args:
29 result.append("--args-for=%s %s" % (apptest_url, " ".join(apptest_args)))
30 result.append(apptest_url)
31 return result
32
33
34 def run_apptest(shell, shell_args, apptest_url, apptest_args, output_test):
35 """Runs shell with the given arguments, retrieves the output and applies
36 |output_test| to determine if the run was successful.
37
38 Args:
39 shell: Wrapper around concrete Mojo shell, implementing devtools Shell
40 interface.
41 shell_args: List of arguments for the shell run.
42 apptest_url: Url of the apptest app to run.
43 apptest_args: Parameters to be passed to the apptest app.
44 output_test: Function accepting the shell output and returning True iff
45 the output indicates a successful run.
46
47 Returns:
48 True iff the test succeeded, False otherwise.
49 """
50 arguments = _build_shell_arguments(shell_args, apptest_url, apptest_args)
51 command_line = "mojo_shell " + " ".join(["%r" % x for x in arguments])
52
53 _logger.debug("Starting: " + command_line)
54 start_time = time.time()
55 (exit_code, output) = shell.RunAndGetOutput(arguments)
56 run_time = time.time() - start_time
57 _logger.debug("Completed: " + command_line)
58
59 # Only log if it took more than 3 second.
60 if run_time >= 3:
61 _logger.info("Test took %.3f seconds: %s" % (run_time, command_line))
62
63 if exit_code or not output_test(output):
64 print 'Failed test: %r' % command_line
65 if exit_code:
66 print ' due to shell exit code %d' % exit_code
67 else:
68 print ' due to test results'
69 print 72 * '-'
70 print output
71 print 72 * '-'
72 return False
73 return True
OLDNEW
« no previous file with comments | « mojo/devtools/common/pylib/android_shell.py ('k') | mojo/devtools/common/pylib/apptest_dart.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698