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

Side by Side Diff: mojo/devtools/common/mojo_test

Issue 1258903002: Extract `mojo_test` - standalone apptest runner in devtools. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Centralize the documentation in mojo_test. Created 5 years, 4 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/devtoolslib/apptest_runner.py ('k') | mojo/tools/apptest_runner.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 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Test runner for Mojo application tests.
7
8 The file describing the list of tests has to be a valid Python program that sets
9 a |tests| global variable, containing entries of the following form:
10
11 {
12 # Required URL for apptest.
13 "test": "mojo:test_app_url",
14 # Optional display name (otherwise the entry for "test" above is used).
15 "name": "mojo:test_app_url (more details)",
16 # Optional test type. Valid values:
17 # * "gtest" (default)
18 # * "gtest_isolated": like "gtest", but run with fixture isolation,
19 # i.e., each test in a fresh mojo_shell)
20 # * "dart".
21 "type": "gtest",
22 # Optional arguments for the apptest.
23 "test-args": ["--an_arg", "another_arg"],
24 # Optional arguments for the shell.
25 "shell-args": ["--some-flag-for-the-shell", "--another-flag"],
26 }
27
28 The program may use the |target_os| global that will be any of ['android',
29 'linux'], indicating the system on which the tests are to be run.
30
31 TODO(vtl|msw): Add a way of specifying data dependencies.
32 """
33
34 import argparse
35 import sys
36
37 from devtoolslib.android_shell import AndroidShell
38 from devtoolslib.linux_shell import LinuxShell
39 from devtoolslib.apptest_runner import run_apptests
40 from devtoolslib import shell_arguments
41
42
43 def main():
44 parser = argparse.ArgumentParser(description="Test runner for Mojo "
45 "application tests.")
46 parser.add_argument("test_list_file", type=file,
47 help="a file listing apptests to run")
48
49 # Arguments indicating the configuration we are targeting.
50 parser.add_argument('--android', help='Run on Android',
51 action='store_true')
52 debug_group = parser.add_mutually_exclusive_group()
53 debug_group.add_argument('--debug', help='Debug build (default)',
54 default=True, action='store_true')
55 debug_group.add_argument('--release', help='Release build', default=False,
56 dest='debug', action='store_false')
57 parser.add_argument('--target-cpu', help='CPU architecture to run for.',
58 choices=['x64', 'x86', 'arm'])
59
60 # Arguments indicating paths to binaries and tools.
61 parser.add_argument('--adb-path', help='Path of the adb binary.')
62 parser.add_argument('--shell-path', help='Path of the Mojo shell binary.')
63 parser.add_argument('--origin-path', help='Path of a directory to be set as '
64 'the origin for mojo: urls')
65 args = parser.parse_args()
66
67 extra_shell_args = []
68 if args.android:
69 if not args.adb_path:
70 print 'Indicate path to adb in --adb-path.'
71 return 1
72 shell = AndroidShell(args.adb_path)
73
74 device_status, error = shell.CheckDevice()
75 if not device_status:
76 print 'Device check failed: ' + error
77 return 1
78
79 if not args.shell_path:
80 print 'Indicate path to the shell binary in --shell-path'
81 return 1
82 shell.InstallApk(args.shell_path)
83
84 if args.origin_path:
85 extra_shell_args.extend(shell_arguments.ConfigureLocalOrigin(
86 shell, args.origin_path, fixed_port=True))
87 else:
88 if not args.shell_path:
89 print 'Indicate path to the shell binary in --shell-path'
90 return 1
91 shell = LinuxShell(args.shell_path)
92
93 target_os = 'android' if args.android else 'linux'
94 test_list_globals = {"target_os": target_os}
95 exec args.test_list_file in test_list_globals
96 apptests_result = run_apptests(shell, extra_shell_args,
97 test_list_globals["tests"])
98 return 0 if apptests_result else 1
99
100 if __name__ == '__main__':
101 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/devtools/common/devtoolslib/apptest_runner.py ('k') | mojo/tools/apptest_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698