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.
6 """A test runner for gtest application tests."""
14 _logging
= logging
.getLogger()
22 #_logging.setLevel(logging.DEBUG)
24 parser
= argparse
.ArgumentParser(description
='A test runner for gtest '
27 parser
.add_argument('apptest_list_file', type=file,
28 help='A file listing apptests to run.')
29 parser
.add_argument('build_dir', type=str,
30 help='The build output directory.')
31 args
= parser
.parse_args()
33 apptest_list
= ast
.literal_eval(args
.apptest_list_file
.read())
34 _logging
.debug("Test list: %s" % apptest_list
)
37 mojo_shell_path
= os
.path
.join(args
.build_dir
, "mojo_shell")
40 for apptest_dict
in apptest_list
:
41 if apptest_dict
.get("disabled"):
44 apptest
= apptest_dict
["test"]
45 apptest_args
= apptest_dict
.get("test-args", [])
46 shell_args
= apptest_dict
.get("shell-args", [])
48 print "Running " + apptest
+ "...",
51 # List the apptest fixtures so they can be run independently for isolation.
52 # TODO(msw): Run some apptests without fixture isolation?
53 fixtures
= gtest
.get_fixtures(mojo_shell_path
, apptest
)
56 print "Failed with no tests found."
60 apptest_result
= "Succeeded"
61 for fixture
in fixtures
:
62 args_for_apptest
= " ".join(["--args-for=" + apptest
,
63 "--gtest_filter=" + fixture
] + apptest_args
)
65 success
= RunApptestInShell(mojo_shell_path
, apptest
,
66 shell_args
+ [args_for_apptest
])
69 apptest_result
= "Failed test(s) in %r" % apptest_dict
77 def RunApptestInShell(mojo_shell_path
, apptest
, shell_args
):
78 return gtest
.run_test([mojo_shell_path
, apptest
] + shell_args
)
81 if __name__
== '__main__':