OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | |
jamesr
2015/01/29 20:12:08
2015
ppi
2015/01/29 23:41:24
Done.
| |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """A test runner for gtest application tests.""" | |
7 | |
8 import argparse | |
9 import ast | |
10 import logging | |
11 import os | |
12 import sys | |
13 | |
14 _logging = logging.getLogger() | |
15 | |
16 import gtest | |
17 | |
18 | |
19 def main(): | |
20 logging.basicConfig() | |
21 # Uncomment to debug: | |
22 #_logging.setLevel(logging.DEBUG) | |
23 | |
24 parser = argparse.ArgumentParser(description='A test runner for gtest ' | |
25 'application tests.') | |
26 | |
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() | |
32 | |
33 apptest_list = ast.literal_eval(args.apptest_list_file.read()) | |
34 _logging.debug("Test list: %s" % apptest_list) | |
35 | |
36 gtest.set_color() | |
37 mojo_shell_path = os.path.join(args.build_dir, "mojo_shell") | |
38 | |
39 exit_code = 0 | |
40 for apptest_dict in apptest_list: | |
41 if apptest_dict.get("disabled"): | |
42 continue | |
43 | |
44 apptest = apptest_dict["test"] | |
45 apptest_args = apptest_dict.get("test-args", []) | |
46 shell_args = apptest_dict.get("shell-args", []) | |
47 | |
48 print "Running " + apptest + "...", | |
49 sys.stdout.flush() | |
50 | |
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) | |
54 | |
55 if not fixtures: | |
56 print "Failed with no tests found." | |
57 exit_code = 1 | |
58 continue | |
59 | |
60 apptest_result = "Succeeded" | |
61 for fixture in fixtures: | |
62 args_for_apptest = " ".join(["--args-for=" + apptest, | |
63 "--gtest_filter=" + fixture] + apptest_args) | |
64 | |
65 success = RunApptestInShell(mojo_shell_path, apptest, | |
66 shell_args + [args_for_apptest]) | |
67 | |
68 if not success: | |
69 apptest_result = "Failed test(s) in %r" % apptest_dict | |
70 exit_code = 1 | |
71 | |
72 print apptest_result | |
73 | |
74 return exit_code | |
75 | |
76 | |
77 def RunApptestInShell(mojo_shell_path, apptest, shell_args): | |
78 return gtest.run_test([mojo_shell_path, apptest] + shell_args) | |
79 | |
80 | |
81 if __name__ == '__main__': | |
82 sys.exit(main()) | |
OLD | NEW |