Remove unused parameter.
[chromium-blink-merge.git] / mojo / tools / apptest_runner.py
blob901babfaa7452f3505b2cccb1131449d35b28db6
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.
6 """A test runner for gtest application tests."""
8 import argparse
9 import ast
10 import logging
11 import os
12 import sys
14 _logging = logging.getLogger()
16 import gtest
19 def main():
20 logging.basicConfig()
21 # Uncomment to debug:
22 #_logging.setLevel(logging.DEBUG)
24 parser = argparse.ArgumentParser(description='A test runner for gtest '
25 'application tests.')
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)
36 gtest.set_color()
37 mojo_shell_path = os.path.join(args.build_dir, "mojo_shell")
39 exit_code = 0
40 for apptest_dict in apptest_list:
41 if apptest_dict.get("disabled"):
42 continue
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 + "...",
49 sys.stdout.flush()
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)
55 if not fixtures:
56 print "Failed with no tests found."
57 exit_code = 1
58 continue
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])
68 if not success:
69 apptest_result = "Failed test(s) in %r" % apptest_dict
70 exit_code = 1
72 print apptest_result
74 return exit_code
77 def RunApptestInShell(mojo_shell_path, apptest, shell_args):
78 return gtest.run_test([mojo_shell_path, apptest] + shell_args)
81 if __name__ == '__main__':
82 sys.exit(main())