| 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 18 matching lines...) Expand all Loading... |
| 29 # Optional test type. Valid values: | 29 # Optional test type. Valid values: |
| 30 # * "gtest" (default) | 30 # * "gtest" (default) |
| 31 # * "gtest_isolated": like "gtest", but run with fixture isolation, | 31 # * "gtest_isolated": like "gtest", but run with fixture isolation, |
| 32 # i.e., each test in a fresh mojo_shell | 32 # i.e., each test in a fresh mojo_shell |
| 33 # * "dart" | 33 # * "dart" |
| 34 "type": "gtest", | 34 "type": "gtest", |
| 35 # Optional arguments to be passed to the apptest. | 35 # Optional arguments to be passed to the apptest. |
| 36 "test-args": ["--an_arg", "another_arg"], | 36 "test-args": ["--an_arg", "another_arg"], |
| 37 # Optional shell arguments. | 37 # Optional shell arguments. |
| 38 "shell-args": ["--some-flag-for-the-shell", "--another-flag"], | 38 "shell-args": ["--some-flag-for-the-shell", "--another-flag"], |
| 39 # Optional timeout in seconds, 60 by default. |
| 40 "timeout": 120, |
| 39 } | 41 } |
| 40 | 42 |
| 41 |test_list_file| may reference the |target_os| global that will be any of | 43 |test_list_file| may reference the |target_os| global that will be any of |
| 42 ['android', 'linux'], indicating the system on which the tests are to be run. | 44 ['android', 'linux'], indicating the system on which the tests are to be run. |
| 43 | 45 |
| 44 Any arguments not recognized by the script will be passed on as shell arguments. | 46 Any arguments not recognized by the script will be passed on as shell arguments. |
| 45 """ | 47 """ |
| 46 | 48 |
| 47 _logger = logging.getLogger() | 49 _logger = logging.getLogger() |
| 48 | 50 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 70 exec script_args.test_list_file in test_list_globals | 72 exec script_args.test_list_file in test_list_globals |
| 71 test_list = test_list_globals["tests"] | 73 test_list = test_list_globals["tests"] |
| 72 | 74 |
| 73 succeeded = True | 75 succeeded = True |
| 74 for test_dict in test_list: | 76 for test_dict in test_list: |
| 75 test = test_dict["test"] | 77 test = test_dict["test"] |
| 76 test_name = test_dict.get("name", test) | 78 test_name = test_dict.get("name", test) |
| 77 test_type = test_dict.get("type", "gtest") | 79 test_type = test_dict.get("type", "gtest") |
| 78 test_args = test_dict.get("test-args", []) | 80 test_args = test_dict.get("test-args", []) |
| 79 shell_args = test_dict.get("shell-args", []) + common_shell_args | 81 shell_args = test_dict.get("shell-args", []) + common_shell_args |
| 82 timeout = test_dict.get("timeout", 60) |
| 80 | 83 |
| 81 _logger.info("Will start: %s" % test_name) | 84 _logger.info("Will start: %s" % test_name) |
| 82 print "Running %s...." % test_name, | 85 print "Running %s...." % test_name, |
| 83 sys.stdout.flush() | 86 sys.stdout.flush() |
| 84 | 87 |
| 85 if test_type == "dart": | 88 if test_type == "dart": |
| 86 apptest_result = apptest_dart.run_dart_apptest(shell, shell_args, test, | 89 apptest_result = apptest_dart.run_dart_apptest(shell, shell_args, test, |
| 87 test_args) | 90 test_args, timeout) |
| 88 elif test_type == "gtest": | 91 elif test_type == "gtest": |
| 89 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, | 92 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, |
| 90 test_args, False) | 93 test_args, timeout, |
| 94 False) |
| 91 elif test_type == "gtest_isolated": | 95 elif test_type == "gtest_isolated": |
| 92 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, | 96 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, |
| 93 test_args, True) | 97 test_args, timeout, |
| 98 True) |
| 94 else: | 99 else: |
| 95 apptest_result = False | 100 apptest_result = False |
| 96 print "Unrecognized test type in %r" % test_dict | 101 print "Unrecognized test type in %r" % test_dict |
| 97 | 102 |
| 98 print "Succeeded" if apptest_result else "Failed" | 103 print "Succeeded" if apptest_result else "Failed" |
| 99 _logger.info("Completed: %s" % test_name) | 104 _logger.info("Completed: %s" % test_name) |
| 100 if not apptest_result: | 105 if not apptest_result: |
| 101 succeeded = False | 106 succeeded = False |
| 102 return 0 if succeeded else 1 | 107 return 0 if succeeded else 1 |
| 103 | 108 |
| 104 if __name__ == '__main__': | 109 if __name__ == '__main__': |
| 105 sys.exit(main()) | 110 sys.exit(main()) |
| OLD | NEW |