| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """High-level apptest runner that runs all tests specified in a list. | 5 """High-level apptest runner that runs all tests specified in a list. |
| 6 | 6 |
| 7 The list of tests has to contain one dictionary per test to be run, in the | 7 TODO(ppi): merge this into `mojo_test` once all clients are switched to use |
| 8 following form: | 8 `mojo_test` instead of calling run_apptests() directly. |
| 9 | |
| 10 { | |
| 11 # Required URL for apptest. | |
| 12 "test": "mojo:test_app_url", | |
| 13 # Optional display name (otherwise the entry for "test" above is used). | |
| 14 "name": "mojo:test_app_url (more details)", | |
| 15 # Optional test type. Valid values: | |
| 16 # * "gtest" (default) | |
| 17 # * "gtest_isolated": like "gtest", but run with fixture isolation, | |
| 18 # i.e., each test in a fresh mojo_shell) | |
| 19 # * "dart". | |
| 20 "type": "gtest", | |
| 21 # Optional arguments for the apptest. | |
| 22 "test-args": ["--an_arg", "another_arg"], | |
| 23 # Optional arguments for the shell. | |
| 24 "shell-args": ["--some-flag-for-the-shell", "--another-flag"], | |
| 25 } | |
| 26 | |
| 27 TODO(vtl|msw): Add a way of specifying data dependencies. | |
| 28 """ | 9 """ |
| 29 | 10 |
| 30 import sys | 11 import sys |
| 31 import logging | 12 import logging |
| 32 | 13 |
| 33 from .apptest_dart import run_dart_apptest | 14 from .apptest_dart import run_dart_apptest |
| 34 from .apptest_gtest import run_gtest_apptest | 15 from .apptest_gtest import run_gtest_apptest |
| 35 | 16 |
| 36 _logger = logging.getLogger() | 17 _logger = logging.getLogger() |
| 37 | 18 |
| 38 | 19 |
| 39 def run_apptests(shell, common_shell_args, test_list): | 20 def run_apptests(shell, common_shell_args, test_list): |
| 40 """Runs the apptests specified in |test_list| using the given |shell|. | 21 """Runs the apptests specified in |test_list| using the given |shell|. |
| 41 | 22 |
| 42 Args: | 23 Args: |
| 43 shell: Shell that will run the tests, see shell.py. | 24 shell: Shell that will run the tests, see shell.py. |
| 44 common_shell_args: Arguments that will be passed to the shell on each run. | 25 common_shell_args: Arguments that will be passed to the shell on each run. |
| 45 These will be appended to the shell-args specified for individual tests. | 26 These will be appended to the shell-args specified for individual tests. |
| 46 test_list: List of tests to be run in the format described in the | 27 test_list: List of tests to be run in the format described in the |
| 47 docstring of this module. | 28 docstring of `mojo_test`. |
| 48 | 29 |
| 49 Returns: | 30 Returns: |
| 50 True iff all tests succeeded, False otherwise. | 31 True iff all tests succeeded, False otherwise. |
| 51 """ | 32 """ |
| 52 succeeded = True | 33 succeeded = True |
| 53 for test_dict in test_list: | 34 for test_dict in test_list: |
| 54 test = test_dict["test"] | 35 test = test_dict["test"] |
| 55 test_name = test_dict.get("name", test) | 36 test_name = test_dict.get("name", test) |
| 56 test_type = test_dict.get("type", "gtest") | 37 test_type = test_dict.get("type", "gtest") |
| 57 test_args = test_dict.get("test-args", []) | 38 test_args = test_dict.get("test-args", []) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 True) | 52 True) |
| 72 else: | 53 else: |
| 73 apptest_result = False | 54 apptest_result = False |
| 74 print "Unrecognized test type in %r" % test_dict | 55 print "Unrecognized test type in %r" % test_dict |
| 75 | 56 |
| 76 print "Succeeded" if apptest_result else "Failed" | 57 print "Succeeded" if apptest_result else "Failed" |
| 77 _logger.info("Completed: %s" % test_name) | 58 _logger.info("Completed: %s" % test_name) |
| 78 if not apptest_result: | 59 if not apptest_result: |
| 79 succeeded = False | 60 succeeded = False |
| 80 return succeeded | 61 return succeeded |
| OLD | NEW |