blob: ca9baa21355f00c0f640da49c36095153a3796c7 [file] [log] [blame]
#!/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.
The file describing the list of tests has to be a valid Python program that sets
a |tests| global variable, containing entries of the following form:
{
# Required URL for apptest.
"test": "mojo:test_app_url",
# Optional display name (otherwise the entry for "test" above is used).
"name": "mojo:test_app_url (more details)",
# Optional test type. Valid values:
# * "gtest" (default)
# * "gtest_isolated": like "gtest", but run with fixture isolation,
# i.e., each test in a fresh mojo_shell)
# * "dart".
"type": "gtest",
# Optional arguments for the apptest.
"test-args": ["--an_arg", "another_arg"],
# Optional arguments for the shell.
"shell-args": ["--some-flag-for-the-shell", "--another-flag"],
}
The program may use the |target_os| global that will be any of ['android',
'linux'], indicating the system on which the tests are to be run.
TODO(vtl|msw): Add a way of specifying data dependencies.
"""
_DESCRIPTION = """Runner for Mojo application tests.
Any arguments not recognized by the script will be passed on as shell arguments.
"""
import argparse
import sys
from devtoolslib.apptest_runner import run_apptests
from devtoolslib import shell_arguments
def main():
parser = argparse.ArgumentParser(description=_DESCRIPTION)
parser.add_argument("test_list_file", type=file,
help="a file listing apptests to run")
# Common shell configuration arguments.
shell_arguments.AddShellArguments(parser)
script_args, shell_args = parser.parse_known_args()
try:
shell, shell_args = shell_arguments.ConfigureShell(script_args, shell_args)
except shell_arguments.ShellConfigurationException as e:
print e
return 1
target_os = 'android' if script_args.android else 'linux'
test_list_globals = {"target_os": target_os}
exec script_args.test_list_file in test_list_globals
apptests_result = run_apptests(shell, shell_args,
test_list_globals["tests"])
return 0 if apptests_result else 1
if __name__ == '__main__':
sys.exit(main())