Chromium Code Reviews| 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 TODO(vtl|msw): Add a way of specifying data dependencies. |
|
ppi
2015/07/29 13:38:43
here.
| |
| 9 a |tests| global variable, containing entries of the following form: | 9 """ |
| 10 | |
| 11 import argparse | |
| 12 import logging | |
| 13 import sys | |
| 14 | |
| 15 from devtoolslib import apptest_dart | |
| 16 from devtoolslib import apptest_gtest | |
| 17 from devtoolslib import shell_arguments | |
| 18 | |
| 19 _DESCRIPTION = """Runner for Mojo application tests. | |
| 20 | |
| 21 |test_list_file| has to be a valid Python program that sets a |tests| global | |
| 22 variable, containing entries of the following form: | |
| 10 | 23 |
| 11 { | 24 { |
| 12 # Required URL for apptest. | 25 # Required URL for apptest. |
| 13 "test": "mojo:test_app_url", | 26 "test": "mojo:test_app_url", |
| 14 # Optional display name (otherwise the entry for "test" above is used). | 27 # Optional display name (otherwise the entry for "test" above is used). |
| 15 "name": "mojo:test_app_url (more details)", | 28 "name": "mojo:test_app_url (more details)", |
| 16 # Optional test type. Valid values: | 29 # Optional test type. Valid values: |
| 17 # * "gtest" (default) | 30 # * "gtest" (default) |
| 18 # * "gtest_isolated": like "gtest", but run with fixture isolation, | 31 # * "gtest_isolated": like "gtest", but run with fixture isolation, |
| 19 # i.e., each test in a fresh mojo_shell) | 32 # i.e., each test in a fresh mojo_shell |
| 20 # * "dart". | 33 # * "dart" |
| 21 "type": "gtest", | 34 "type": "gtest", |
| 22 # Optional arguments for the apptest. | 35 # Optional arguments to be passed to the apptest. |
| 23 "test-args": ["--an_arg", "another_arg"], | 36 "test-args": ["--an_arg", "another_arg"], |
| 24 # Optional arguments for the shell. | 37 # Optional shell arguments. |
| 25 "shell-args": ["--some-flag-for-the-shell", "--another-flag"], | 38 "shell-args": ["--some-flag-for-the-shell", "--another-flag"], |
| 26 } | 39 } |
| 27 | 40 |
| 28 The program may use the |target_os| global that will be any of ['android', | 41 |test_list_file| may reference the |target_os| global that will be any of |
| 29 'linux'], indicating the system on which the tests are to be run. | 42 ['android', 'linux'], indicating the system on which the tests are to be run. |
| 30 | |
| 31 TODO(vtl|msw): Add a way of specifying data dependencies. | |
|
qsr
2015/07/29 13:37:57
Where is this todo gone?
| |
| 32 """ | |
| 33 | |
| 34 _DESCRIPTION = """Runner for Mojo application tests. | |
| 35 | 43 |
| 36 Any arguments not recognized by the script will be passed on as shell arguments. | 44 Any arguments not recognized by the script will be passed on as shell arguments. |
| 37 """ | 45 """ |
| 38 | 46 |
| 39 import argparse | |
| 40 import logging | |
| 41 import sys | |
| 42 | |
| 43 from devtoolslib import apptest_dart | |
| 44 from devtoolslib import apptest_gtest | |
| 45 from devtoolslib import shell_arguments | |
| 46 | |
| 47 _logger = logging.getLogger() | 47 _logger = logging.getLogger() |
| 48 | 48 |
| 49 | 49 |
| 50 def main(): | 50 def main(): |
| 51 parser = argparse.ArgumentParser(description=_DESCRIPTION) | 51 parser = argparse.ArgumentParser( |
| 52 formatter_class=argparse.RawDescriptionHelpFormatter, | |
| 53 description=_DESCRIPTION) | |
| 52 parser.add_argument("test_list_file", type=file, | 54 parser.add_argument("test_list_file", type=file, |
| 53 help="a file listing apptests to run") | 55 help="a file listing apptests to run") |
| 54 | 56 |
| 55 # Common shell configuration arguments. | 57 # Common shell configuration arguments. |
| 56 shell_arguments.add_shell_arguments(parser) | 58 shell_arguments.add_shell_arguments(parser) |
| 57 script_args, common_shell_args = parser.parse_known_args() | 59 script_args, common_shell_args = parser.parse_known_args() |
| 58 | 60 |
| 59 try: | 61 try: |
| 60 shell, common_shell_args = shell_arguments.configure_shell( | 62 shell, common_shell_args = shell_arguments.configure_shell( |
| 61 script_args, common_shell_args) | 63 script_args, common_shell_args) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 print "Unrecognized test type in %r" % test_dict | 96 print "Unrecognized test type in %r" % test_dict |
| 95 | 97 |
| 96 print "Succeeded" if apptest_result else "Failed" | 98 print "Succeeded" if apptest_result else "Failed" |
| 97 _logger.info("Completed: %s" % test_name) | 99 _logger.info("Completed: %s" % test_name) |
| 98 if not apptest_result: | 100 if not apptest_result: |
| 99 succeeded = False | 101 succeeded = False |
| 100 return 0 if succeeded else 1 | 102 return 0 if succeeded else 1 |
| 101 | 103 |
| 102 if __name__ == '__main__': | 104 if __name__ == '__main__': |
| 103 sys.exit(main()) | 105 sys.exit(main()) |
| OLD | NEW |