| Index: mojo/devtools/common/mojo_test
|
| diff --git a/mojo/devtools/common/mojo_test b/mojo/devtools/common/mojo_test
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..2c8c344ec6fcf1848f9912b3e82ad7c1418ed086
|
| --- /dev/null
|
| +++ b/mojo/devtools/common/mojo_test
|
| @@ -0,0 +1,75 @@
|
| +#!/usr/bin/env python
|
| +# Copyright 2015 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +"""Test runner for Mojo application tests."""
|
| +
|
| +import argparse
|
| +import sys
|
| +
|
| +from devtoolslib.android_shell import AndroidShell
|
| +from devtoolslib.linux_shell import LinuxShell
|
| +from devtoolslib.apptest_runner import run_apptests
|
| +from devtoolslib import shell_arguments
|
| +
|
| +
|
| +def main():
|
| + parser = argparse.ArgumentParser(description="Test runner for Mojo "
|
| + "application tests.")
|
| + parser.add_argument("test_list_file", type=file,
|
| + help="a file listing apptests to run")
|
| +
|
| + # Arguments indicating the configuration we are targeting.
|
| + parser.add_argument('--android', help='Run on Android',
|
| + action='store_true')
|
| + debug_group = parser.add_mutually_exclusive_group()
|
| + debug_group.add_argument('--debug', help='Debug build (default)',
|
| + default=True, action='store_true')
|
| + debug_group.add_argument('--release', help='Release build', default=False,
|
| + dest='debug', action='store_false')
|
| + parser.add_argument('--target-cpu', help='CPU architecture to run for.',
|
| + choices=['x64', 'x86', 'arm'])
|
| +
|
| + # Arguments indicating paths to binaries and tools.
|
| + parser.add_argument('--adb-path', help='Path of the adb binary.')
|
| + parser.add_argument('--shell-path', help='Path of the Mojo shell binary.')
|
| + parser.add_argument('--origin-path', help='Path of a directory to be set as '
|
| + 'the origin for mojo: urls')
|
| + args = parser.parse_args()
|
| +
|
| + extra_shell_args = []
|
| + if args.android:
|
| + if not args.adb_path:
|
| + print 'Indicate path to adb in --adb-path.'
|
| + return 1
|
| + shell = AndroidShell(args.adb_path)
|
| +
|
| + device_status, error = shell.CheckDevice()
|
| + if not device_status:
|
| + print 'Device check failed: ' + error
|
| + return 1
|
| +
|
| + if not args.shell_path:
|
| + print 'Indicate path to the shell binary in --shell-path'
|
| + return 1
|
| + shell.InstallApk(args.shell_path)
|
| +
|
| + if args.origin_path:
|
| + extra_shell_args.extend(shell_arguments.ConfigureLocalOrigin(
|
| + shell, args.origin_path, fixed_port=True))
|
| + else:
|
| + if not args.shell_path:
|
| + print 'Indicate path to the shell binary in --shell-path'
|
| + return 1
|
| + shell = LinuxShell(args.shell_path)
|
| +
|
| + target_os = 'android' if args.android else 'linux'
|
| + test_list_globals = {"target_os": target_os}
|
| + exec args.test_list_file in test_list_globals
|
| + apptests_result = run_apptests(shell, extra_shell_args,
|
| + test_list_globals["tests"])
|
| + return 0 if apptests_result else 1
|
| +
|
| +if __name__ == '__main__':
|
| + sys.exit(main())
|
|
|