| 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 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 # * "gtest_isolated": like "gtest", but run with fixture isolation, | 32 # * "gtest_isolated": like "gtest", but run with fixture isolation, |
| 33 # i.e., each test in a fresh mojo_shell | 33 # i.e., each test in a fresh mojo_shell |
| 34 # * "dart" | 34 # * "dart" |
| 35 "type": "gtest", | 35 "type": "gtest", |
| 36 # Optional arguments to be passed to the apptest. | 36 # Optional arguments to be passed to the apptest. |
| 37 "test-args": ["--an_arg", "another_arg"], | 37 "test-args": ["--an_arg", "another_arg"], |
| 38 # Optional shell arguments. | 38 # Optional shell arguments. |
| 39 "shell-args": ["--some-flag-for-the-shell", "--another-flag"], | 39 "shell-args": ["--some-flag-for-the-shell", "--another-flag"], |
| 40 # Optional timeout in seconds, 60 by default. | 40 # Optional timeout in seconds, 60 by default. |
| 41 "timeout": 120, | 41 "timeout": 120, |
| 42 # Optional override for dart content handler strict mode (on by default). |
| 43 "dart_strict_mode": False, |
| 42 } | 44 } |
| 43 | 45 |
| 44 |test_list_file| may reference the |target_os| global that will be any of | 46 |test_list_file| may reference the |target_os| global that will be any of |
| 45 ['android', 'linux'], indicating the system on which the tests are to be run. | 47 ['android', 'linux'], indicating the system on which the tests are to be run. |
| 46 | 48 |
| 47 Any arguments not recognized by the script will be passed on as shell arguments. | 49 Any arguments not recognized by the script will be passed on as shell arguments. |
| 48 """ | 50 """ |
| 49 | 51 |
| 50 _logger = logging.getLogger() | 52 _logger = logging.getLogger() |
| 51 | 53 |
| 52 _CACHE_SERVICE_URL = 'mojo:url_response_disk_cache' | 54 _CACHE_SERVICE_URL = 'mojo:url_response_disk_cache' |
| 53 _NETWORK_SERVICE_URL = 'mojo:network_service' | 55 _NETWORK_SERVICE_URL = 'mojo:network_service' |
| 56 _DART_STRICT_MODE_ARG = ('--args-for=mojo:dart_content_handler ' |
| 57 '--enable-strict-mode') |
| 54 | 58 |
| 55 | 59 |
| 56 def main(): | 60 def main(): |
| 57 parser = argparse.ArgumentParser( | 61 parser = argparse.ArgumentParser( |
| 58 formatter_class=argparse.RawDescriptionHelpFormatter, | 62 formatter_class=argparse.RawDescriptionHelpFormatter, |
| 59 description=_DESCRIPTION) | 63 description=_DESCRIPTION) |
| 60 parser.add_argument("test_list_file", type=file, | 64 parser.add_argument("test_list_file", type=file, |
| 61 help="a file listing apptests to run") | 65 help="a file listing apptests to run") |
| 62 shell_config.add_shell_arguments(parser) | 66 shell_config.add_shell_arguments(parser) |
| 63 | 67 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 81 test_list = test_list_globals["tests"] | 85 test_list = test_list_globals["tests"] |
| 82 | 86 |
| 83 succeeded = True | 87 succeeded = True |
| 84 for test_dict in test_list: | 88 for test_dict in test_list: |
| 85 test = test_dict["test"] | 89 test = test_dict["test"] |
| 86 test_name = test_dict.get("name", test) | 90 test_name = test_dict.get("name", test) |
| 87 test_type = test_dict.get("type", "gtest") | 91 test_type = test_dict.get("type", "gtest") |
| 88 test_args = test_dict.get("test-args", []) | 92 test_args = test_dict.get("test-args", []) |
| 89 shell_args = test_dict.get("shell-args", []) + common_shell_args | 93 shell_args = test_dict.get("shell-args", []) + common_shell_args |
| 90 timeout = test_dict.get("timeout", 60) | 94 timeout = test_dict.get("timeout", 60) |
| 95 dart_strict_mode = test_dict.get("dart_strict_mode", True) |
| 96 if dart_strict_mode: |
| 97 shell_args.append(_DART_STRICT_MODE_ARG) |
| 91 | 98 |
| 92 _logger.info("Will start: %s" % test_name) | 99 _logger.info("Will start: %s" % test_name) |
| 93 print "Running %s...." % test_name, | 100 print "Running %s...." % test_name, |
| 94 sys.stdout.flush() | 101 sys.stdout.flush() |
| 95 | 102 |
| 96 if test_type == "dart": | 103 if test_type == "dart": |
| 97 apptest_result = apptest_dart.run_dart_apptest(shell, shell_args, test, | 104 apptest_result = apptest_dart.run_dart_apptest(shell, shell_args, test, |
| 98 test_args, timeout) | 105 test_args, timeout) |
| 99 elif test_type == "gtest": | 106 elif test_type == "gtest": |
| 100 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, | 107 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, |
| 101 test_args, timeout, | 108 test_args, timeout, |
| 102 False) | 109 False) |
| 103 elif test_type == "gtest_isolated": | 110 elif test_type == "gtest_isolated": |
| 104 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, | 111 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, |
| 105 test_args, timeout, | 112 test_args, timeout, |
| 106 True) | 113 True) |
| 107 else: | 114 else: |
| 108 apptest_result = False | 115 apptest_result = False |
| 109 print "Unrecognized test type in %r" % test_dict | 116 print "Unrecognized test type in %r" % test_dict |
| 110 | 117 |
| 111 print "Succeeded" if apptest_result else "Failed" | 118 print "Succeeded" if apptest_result else "Failed" |
| 112 _logger.info("Completed: %s" % test_name) | 119 _logger.info("Completed: %s" % test_name) |
| 113 if not apptest_result: | 120 if not apptest_result: |
| 114 succeeded = False | 121 succeeded = False |
| 115 return 0 if succeeded else 1 | 122 return 0 if succeeded else 1 |
| 116 | 123 |
| 117 if __name__ == '__main__': | 124 if __name__ == '__main__': |
| 118 sys.exit(main()) | 125 sys.exit(main()) |
| OLD | NEW |