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

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: 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
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 import argparse
9 import sys
10
11 from devtoolslib.android_shell import AndroidShell
12 from devtoolslib.linux_shell import LinuxShell
13 from devtoolslib.apptest_runner import run_apptests
14 from devtoolslib import shell_arguments
15
16
17 def main():
18 parser = argparse.ArgumentParser(description="Test runner for Mojo "
19 "application tests.")
20 parser.add_argument("test_list_file", type=file,
21 help="a file listing apptests to run")
22
23 # Arguments indicating the configuration we are targeting.
24 parser.add_argument('--android', help='Run on Android',
25 action='store_true')
26 debug_group = parser.add_mutually_exclusive_group()
27 debug_group.add_argument('--debug', help='Debug build (default)',
28 default=True, action='store_true')
29 debug_group.add_argument('--release', help='Release build', default=False,
30 dest='debug', action='store_false')
31 parser.add_argument('--target-cpu', help='CPU architecture to run for.',
32 choices=['x64', 'x86', 'arm'])
33
34 # Arguments indicating paths to binaries and tools.
35 parser.add_argument('--adb-path', help='Path of the adb binary.')
36 parser.add_argument('--shell-path', help='Path of the Mojo shell binary.')
37 parser.add_argument('--origin-path', help='Path of a directory to be set as '
38 'the origin for mojo: urls')
39 args = parser.parse_args()
40
41 extra_shell_args = []
42 if args.android:
43 if not args.adb_path:
44 print 'Indicate path to adb in --adb-path.'
45 return 1
46 shell = AndroidShell(args.adb_path)
47
48 device_status, error = shell.CheckDevice()
49 if not device_status:
50 print 'Device check failed: ' + error
51 return 1
52
53 if not args.shell_path:
54 print 'Indicate path to the shell binary in --shell-path'
55 return 1
56 shell.InstallApk(args.shell_path)
57
58 if args.origin_path:
59 extra_shell_args.extend(shell_arguments.ConfigureLocalOrigin(
60 shell, args.origin_path, fixed_port=True))
61 else:
62 if not args.shell_path:
63 print 'Indicate path to the shell binary in --shell-path'
64 return 1
65 shell = LinuxShell(args.shell_path)
66
67 target_os = 'android' if args.android else 'linux'
68 test_list_globals = {"target_os": target_os}
69 exec args.test_list_file in test_list_globals
70 apptests_result = run_apptests(shell, extra_shell_args,
71 test_list_globals["tests"])
72 return 0 if apptests_result else 1
73
74 if __name__ == '__main__':
75 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698