| 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 | 14 |
| 15 from devtoolslib import apptest_dart | 15 from devtoolslib import apptest_dart |
| 16 from devtoolslib import apptest_gtest | 16 from devtoolslib import apptest_gtest |
| 17 from devtoolslib import shell_arguments | 17 from devtoolslib import shell_arguments |
| 18 from devtoolslib import shell_config |
| 18 | 19 |
| 19 _DESCRIPTION = """Runner for Mojo application tests. | 20 _DESCRIPTION = """Runner for Mojo application tests. |
| 20 | 21 |
| 21 |test_list_file| has to be a valid Python program that sets a |tests| global | 22 |test_list_file| has to be a valid Python program that sets a |tests| global |
| 22 variable, containing entries of the following form: | 23 variable, containing entries of the following form: |
| 23 | 24 |
| 24 { | 25 { |
| 25 # Required URL for apptest. | 26 # Required URL for apptest. |
| 26 "test": "mojo:test_app_url", | 27 "test": "mojo:test_app_url", |
| 27 # Optional display name (otherwise the entry for "test" above is used). | 28 # Optional display name (otherwise the entry for "test" above is used). |
| (...skipping 20 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 _logger = logging.getLogger() | 50 _logger = logging.getLogger() |
| 50 | 51 |
| 51 | 52 |
| 52 def main(): | 53 def main(): |
| 53 parser = argparse.ArgumentParser( | 54 parser = argparse.ArgumentParser( |
| 54 formatter_class=argparse.RawDescriptionHelpFormatter, | 55 formatter_class=argparse.RawDescriptionHelpFormatter, |
| 55 description=_DESCRIPTION) | 56 description=_DESCRIPTION) |
| 56 parser.add_argument("test_list_file", type=file, | 57 parser.add_argument("test_list_file", type=file, |
| 57 help="a file listing apptests to run") | 58 help="a file listing apptests to run") |
| 59 shell_config.add_shell_arguments(parser) |
| 58 | 60 |
| 59 # Common shell configuration arguments. | 61 script_args, shell_args = parser.parse_known_args() |
| 60 shell_arguments.add_shell_arguments(parser) | 62 config = shell_config.get_shell_config(script_args) |
| 61 script_args, common_shell_args = parser.parse_known_args() | |
| 62 | 63 |
| 63 try: | 64 try: |
| 64 shell, common_shell_args = shell_arguments.configure_shell( | 65 shell, common_shell_args = shell_arguments.get_shell(config, shell_args) |
| 65 script_args, common_shell_args) | |
| 66 except shell_arguments.ShellConfigurationException as e: | 66 except shell_arguments.ShellConfigurationException as e: |
| 67 print e | 67 print e |
| 68 return 1 | 68 return 1 |
| 69 | 69 |
| 70 target_os = "android" if script_args.android else "linux" | 70 target_os = "android" if script_args.android else "linux" |
| 71 test_list_globals = {"target_os": target_os} | 71 test_list_globals = {"target_os": target_os} |
| 72 exec script_args.test_list_file in test_list_globals | 72 exec script_args.test_list_file in test_list_globals |
| 73 test_list = test_list_globals["tests"] | 73 test_list = test_list_globals["tests"] |
| 74 | 74 |
| 75 succeeded = True | 75 succeeded = True |
| (...skipping 25 matching lines...) Expand all Loading... |
| 101 print "Unrecognized test type in %r" % test_dict | 101 print "Unrecognized test type in %r" % test_dict |
| 102 | 102 |
| 103 print "Succeeded" if apptest_result else "Failed" | 103 print "Succeeded" if apptest_result else "Failed" |
| 104 _logger.info("Completed: %s" % test_name) | 104 _logger.info("Completed: %s" % test_name) |
| 105 if not apptest_result: | 105 if not apptest_result: |
| 106 succeeded = False | 106 succeeded = False |
| 107 return 0 if succeeded else 1 | 107 return 0 if succeeded else 1 |
| 108 | 108 |
| 109 if __name__ == '__main__': | 109 if __name__ == '__main__': |
| 110 sys.exit(main()) | 110 sys.exit(main()) |
| OLD | NEW |