OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """A test runner for gtest application tests.""" | 6 """A test runner for gtest application tests.""" |
7 | 7 |
8 import argparse | 8 import argparse |
9 import ast | 9 import ast |
10 import logging | 10 import logging |
11 import os | 11 import os |
12 import sys | 12 import sys |
13 | 13 |
14 _logging = logging.getLogger() | 14 _logging = logging.getLogger() |
15 | 15 |
16 import gtest | 16 import gtest |
17 | 17 |
18 | 18 |
19 def main(): | 19 def main(): |
20 logging.basicConfig() | 20 logging.basicConfig() |
| 21 # TODO(msw): Restore the logging level when apptests are working as expected. |
21 # Uncomment to debug: | 22 # Uncomment to debug: |
22 #_logging.setLevel(logging.DEBUG) | 23 _logging.setLevel(logging.DEBUG) |
23 | 24 |
24 parser = argparse.ArgumentParser(description='A test runner for gtest ' | 25 parser = argparse.ArgumentParser(description='A test runner for gtest ' |
25 'application tests.') | 26 'application tests.') |
26 | 27 |
27 parser.add_argument('apptest_list_file', type=file, | 28 parser.add_argument('apptest_list_file', type=file, |
28 help='A file listing apptests to run.') | 29 help='A file listing apptests to run.') |
29 parser.add_argument('build_dir', type=str, | 30 parser.add_argument('build_dir', type=str, |
30 help='The build output directory.') | 31 help='The build output directory.') |
31 args = parser.parse_args() | 32 args = parser.parse_args() |
32 | 33 |
(...skipping 19 matching lines...) Expand all Loading... |
52 # TODO(msw): Run some apptests without fixture isolation? | 53 # TODO(msw): Run some apptests without fixture isolation? |
53 fixtures = gtest.get_fixtures(mojo_shell_path, apptest) | 54 fixtures = gtest.get_fixtures(mojo_shell_path, apptest) |
54 | 55 |
55 if not fixtures: | 56 if not fixtures: |
56 print "Failed with no tests found." | 57 print "Failed with no tests found." |
57 exit_code = 1 | 58 exit_code = 1 |
58 continue | 59 continue |
59 | 60 |
60 apptest_result = "Succeeded" | 61 apptest_result = "Succeeded" |
61 for fixture in fixtures: | 62 for fixture in fixtures: |
62 args_for_apptest = " ".join(["--args-for=" + apptest, | 63 args_for_apptest = " ".join(["--gtest_filter=" + fixture] + apptest_args) |
63 "--gtest_filter=" + fixture] + apptest_args) | |
64 | 64 |
65 success = RunApptestInShell(mojo_shell_path, apptest, | 65 success = RunApptestInShell(mojo_shell_path, apptest, |
66 shell_args + [args_for_apptest]) | 66 shell_args + [args_for_apptest]) |
67 | 67 |
68 if not success: | 68 if not success: |
69 apptest_result = "Failed test(s) in %r" % apptest_dict | 69 apptest_result = "Failed test(s) in %r" % apptest_dict |
70 exit_code = 1 | 70 exit_code = 1 |
71 | 71 |
72 print apptest_result | 72 print apptest_result |
73 | 73 |
74 return exit_code | 74 return exit_code |
75 | 75 |
76 | 76 |
77 def RunApptestInShell(mojo_shell_path, apptest, shell_args): | 77 def RunApptestInShell(mojo_shell_path, apptest, shell_args): |
78 return gtest.run_test([mojo_shell_path, apptest] + shell_args) | 78 return gtest.run_test([mojo_shell_path, apptest] + shell_args) |
79 | 79 |
80 | 80 |
81 if __name__ == '__main__': | 81 if __name__ == '__main__': |
82 sys.exit(main()) | 82 sys.exit(main()) |
OLD | NEW |