| 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 The file describing the list of tests has to be a valid Python program that sets | 8 The file describing the list of tests has to be a valid Python program that sets |
| 9 a |tests| global variable, containing entries of the following form: | 9 a |tests| global variable, containing entries of the following form: |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 TODO(vtl|msw): Add a way of specifying data dependencies. | 31 TODO(vtl|msw): Add a way of specifying data dependencies. |
| 32 """ | 32 """ |
| 33 | 33 |
| 34 _DESCRIPTION = """Runner for Mojo application tests. | 34 _DESCRIPTION = """Runner for Mojo application tests. |
| 35 | 35 |
| 36 Any arguments not recognized by the script will be passed on as shell arguments. | 36 Any arguments not recognized by the script will be passed on as shell arguments. |
| 37 """ | 37 """ |
| 38 | 38 |
| 39 import argparse | 39 import argparse |
| 40 import logging |
| 40 import sys | 41 import sys |
| 41 | 42 |
| 42 from devtoolslib.apptest_runner import run_apptests | 43 from devtoolslib import apptest_dart |
| 44 from devtoolslib import apptest_gtest |
| 43 from devtoolslib import shell_arguments | 45 from devtoolslib import shell_arguments |
| 44 | 46 |
| 47 _logger = logging.getLogger() |
| 48 |
| 45 | 49 |
| 46 def main(): | 50 def main(): |
| 47 parser = argparse.ArgumentParser(description=_DESCRIPTION) | 51 parser = argparse.ArgumentParser(description=_DESCRIPTION) |
| 48 parser.add_argument("test_list_file", type=file, | 52 parser.add_argument("test_list_file", type=file, |
| 49 help="a file listing apptests to run") | 53 help="a file listing apptests to run") |
| 50 | 54 |
| 51 # Common shell configuration arguments. | 55 # Common shell configuration arguments. |
| 52 shell_arguments.AddShellArguments(parser) | 56 shell_arguments.AddShellArguments(parser) |
| 53 script_args, shell_args = parser.parse_known_args() | 57 script_args, common_shell_args = parser.parse_known_args() |
| 54 | 58 |
| 55 try: | 59 try: |
| 56 shell, shell_args = shell_arguments.ConfigureShell(script_args, shell_args) | 60 shell, common_shell_args = shell_arguments.ConfigureShell(script_args, |
| 61 common_shell_args) |
| 57 except shell_arguments.ShellConfigurationException as e: | 62 except shell_arguments.ShellConfigurationException as e: |
| 58 print e | 63 print e |
| 59 return 1 | 64 return 1 |
| 60 | 65 |
| 61 target_os = 'android' if script_args.android else 'linux' | 66 target_os = "android" if script_args.android else "linux" |
| 62 test_list_globals = {"target_os": target_os} | 67 test_list_globals = {"target_os": target_os} |
| 63 exec script_args.test_list_file in test_list_globals | 68 exec script_args.test_list_file in test_list_globals |
| 64 apptests_result = run_apptests(shell, shell_args, | 69 test_list = test_list_globals["tests"] |
| 65 test_list_globals["tests"]) | 70 |
| 66 return 0 if apptests_result else 1 | 71 succeeded = True |
| 72 for test_dict in test_list: |
| 73 test = test_dict["test"] |
| 74 test_name = test_dict.get("name", test) |
| 75 test_type = test_dict.get("type", "gtest") |
| 76 test_args = test_dict.get("test-args", []) |
| 77 shell_args = test_dict.get("shell-args", []) + common_shell_args |
| 78 |
| 79 _logger.info("Will start: %s" % test_name) |
| 80 print "Running %s...." % test_name, |
| 81 sys.stdout.flush() |
| 82 |
| 83 if test_type == "dart": |
| 84 apptest_result = apptest_dart.run_dart_apptest(shell, shell_args, test, |
| 85 test_args) |
| 86 elif test_type == "gtest": |
| 87 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, |
| 88 test_args, False) |
| 89 elif test_type == "gtest_isolated": |
| 90 apptest_result = apptest_gtest.run_gtest_apptest(shell, shell_args, test, |
| 91 test_args, True) |
| 92 else: |
| 93 apptest_result = False |
| 94 print "Unrecognized test type in %r" % test_dict |
| 95 |
| 96 print "Succeeded" if apptest_result else "Failed" |
| 97 _logger.info("Completed: %s" % test_name) |
| 98 if not apptest_result: |
| 99 succeeded = False |
| 100 return 0 if succeeded else 1 |
| 67 | 101 |
| 68 if __name__ == '__main__': | 102 if __name__ == '__main__': |
| 69 sys.exit(main()) | 103 sys.exit(main()) |
| OLD | NEW |