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 """Test runner for Mojo application tests. | 6 """Test runner for Mojo application tests. |
7 | 7 |
8 TODO(vtl|msw): Add a way of specifying data dependencies. | 8 TODO(vtl|msw): Add a way of specifying data dependencies. |
9 """ | 9 """ |
10 | 10 |
11 import argparse | 11 import argparse |
12 import logging | 12 import logging |
13 import sys | 13 import sys |
14 import os.path | 14 import os.path |
15 | 15 |
16 from devtoolslib import apptest_dart | 16 from devtoolslib import apptest_dart |
17 from devtoolslib import apptest_gtest | 17 from devtoolslib import apptest_gtest |
18 from devtoolslib import shell_arguments | 18 from devtoolslib import shell_arguments |
19 from devtoolslib import shell_config | 19 from devtoolslib import shell_config |
| 20 from devtoolslib.utils import disable_output_buffering |
20 | 21 |
21 _DESCRIPTION = """Runner for Mojo application tests. | 22 _DESCRIPTION = """Runner for Mojo application tests. |
22 | 23 |
23 |test_list_file| has to be a valid Python program that sets a |tests| global | 24 |test_list_file| has to be a valid Python program that sets a |tests| global |
24 variable, containing entries of the following form: | 25 variable, containing entries of the following form: |
25 | 26 |
26 { | 27 { |
27 # Required URL for apptest. | 28 # Required URL for apptest. |
28 "test": "mojo:test_app_url", | 29 "test": "mojo:test_app_url", |
29 # Optional display name (otherwise the entry for "test" above is used). | 30 # Optional display name (otherwise the entry for "test" above is used). |
(...skipping 22 matching lines...) Expand all Loading... |
52 | 53 |
53 _logger = logging.getLogger() | 54 _logger = logging.getLogger() |
54 | 55 |
55 _CACHE_SERVICE_URL = 'mojo:url_response_disk_cache' | 56 _CACHE_SERVICE_URL = 'mojo:url_response_disk_cache' |
56 _NETWORK_SERVICE_URL = 'mojo:network_service' | 57 _NETWORK_SERVICE_URL = 'mojo:network_service' |
57 _DART_STRICT_MODE_ARG = ('--args-for=mojo:dart_content_handler ' | 58 _DART_STRICT_MODE_ARG = ('--args-for=mojo:dart_content_handler ' |
58 '--enable-strict-mode') | 59 '--enable-strict-mode') |
59 | 60 |
60 | 61 |
61 def main(): | 62 def main(): |
| 63 disable_output_buffering() |
62 parser = argparse.ArgumentParser( | 64 parser = argparse.ArgumentParser( |
63 formatter_class=argparse.RawDescriptionHelpFormatter, | 65 formatter_class=argparse.RawDescriptionHelpFormatter, |
64 description=_DESCRIPTION) | 66 description=_DESCRIPTION) |
65 parser.add_argument("test_list_file", type=file, | 67 parser.add_argument("test_list_file", type=file, |
66 help="a file listing apptests to run") | 68 help="a file listing apptests to run") |
67 shell_config.add_shell_arguments(parser) | 69 shell_config.add_shell_arguments(parser) |
68 | 70 |
69 script_args, shell_args = parser.parse_known_args() | 71 script_args, shell_args = parser.parse_known_args() |
70 | 72 |
71 try: | 73 try: |
(...skipping 23 matching lines...) Expand all Loading... |
95 test_type = test_dict.get("type", "gtest") | 97 test_type = test_dict.get("type", "gtest") |
96 test_args = test_dict.get("test-args", []) | 98 test_args = test_dict.get("test-args", []) |
97 shell_args = test_dict.get("shell-args", []) + common_shell_args | 99 shell_args = test_dict.get("shell-args", []) + common_shell_args |
98 timeout = test_dict.get("timeout", 60) | 100 timeout = test_dict.get("timeout", 60) |
99 dart_strict_mode = test_dict.get("dart_strict_mode", True) | 101 dart_strict_mode = test_dict.get("dart_strict_mode", True) |
100 if dart_strict_mode: | 102 if dart_strict_mode: |
101 shell_args.append(_DART_STRICT_MODE_ARG) | 103 shell_args.append(_DART_STRICT_MODE_ARG) |
102 | 104 |
103 _logger.info("Will start: %s" % test_name) | 105 _logger.info("Will start: %s" % test_name) |
104 print "Running %s...." % test_name, | 106 print "Running %s...." % test_name, |
105 sys.stdout.flush() | |
106 | 107 |
107 if test_type == "dart": | 108 if test_type == "dart": |
108 apptest_result = apptest_dart.run_dart_apptest(shell, shell_args, test, | 109 apptest_result = apptest_dart.run_dart_apptest(shell, shell_args, test, |
109 test_args, timeout) | 110 test_args, timeout) |
110 elif test_type == "gtest": | 111 elif test_type == "gtest": |
111 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, | 112 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, |
112 test_args, timeout, | 113 test_args, timeout, |
113 False) | 114 False) |
114 elif test_type == "gtest_isolated": | 115 elif test_type == "gtest_isolated": |
115 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, | 116 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, |
116 test_args, timeout, | 117 test_args, timeout, |
117 True) | 118 True) |
118 else: | 119 else: |
119 apptest_result = False | 120 apptest_result = False |
120 print "Unrecognized test type in %r" % test_dict | 121 print "Unrecognized test type in %r" % test_dict |
121 | 122 |
122 print "Succeeded" if apptest_result else "Failed" | 123 print "Succeeded" if apptest_result else "Failed" |
123 _logger.info("Completed: %s" % test_name) | 124 _logger.info("Completed: %s" % test_name) |
124 if not apptest_result: | 125 if not apptest_result: |
125 succeeded = False | 126 succeeded = False |
126 return 0 if succeeded else 1 | 127 return 0 if succeeded else 1 |
127 | 128 |
128 if __name__ == '__main__': | 129 if __name__ == '__main__': |
129 sys.exit(main()) | 130 sys.exit(main()) |
OLD | NEW |