| OLD | NEW |
| (Empty) |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """High-level apptest runner that runs all tests specified in a list. | |
| 6 | |
| 7 TODO(ppi): merge this into `mojo_test` once all clients are switched to use | |
| 8 `mojo_test` instead of calling run_apptests() directly. | |
| 9 """ | |
| 10 | |
| 11 import sys | |
| 12 import logging | |
| 13 | |
| 14 from .apptest_dart import run_dart_apptest | |
| 15 from .apptest_gtest import run_gtest_apptest | |
| 16 | |
| 17 _logger = logging.getLogger() | |
| 18 | |
| 19 | |
| 20 def run_apptests(shell, common_shell_args, test_list): | |
| 21 """Runs the apptests specified in |test_list| using the given |shell|. | |
| 22 | |
| 23 Args: | |
| 24 shell: Shell that will run the tests, see shell.py. | |
| 25 common_shell_args: Arguments that will be passed to the shell on each run. | |
| 26 These will be appended to the shell-args specified for individual tests. | |
| 27 test_list: List of tests to be run in the format described in the | |
| 28 docstring of `mojo_test`. | |
| 29 | |
| 30 Returns: | |
| 31 True iff all tests succeeded, False otherwise. | |
| 32 """ | |
| 33 succeeded = True | |
| 34 for test_dict in test_list: | |
| 35 test = test_dict["test"] | |
| 36 test_name = test_dict.get("name", test) | |
| 37 test_type = test_dict.get("type", "gtest") | |
| 38 test_args = test_dict.get("test-args", []) | |
| 39 shell_args = test_dict.get("shell-args", []) + common_shell_args | |
| 40 | |
| 41 _logger.info("Will start: %s" % test_name) | |
| 42 print "Running %s...." % test_name, | |
| 43 sys.stdout.flush() | |
| 44 | |
| 45 if test_type == "dart": | |
| 46 apptest_result = run_dart_apptest(shell, shell_args, test, test_args) | |
| 47 elif test_type == "gtest": | |
| 48 apptest_result = run_gtest_apptest(shell, shell_args, test, test_args, | |
| 49 False) | |
| 50 elif test_type == "gtest_isolated": | |
| 51 apptest_result = run_gtest_apptest(shell, shell_args, test, test_args, | |
| 52 True) | |
| 53 else: | |
| 54 apptest_result = False | |
| 55 print "Unrecognized test type in %r" % test_dict | |
| 56 | |
| 57 print "Succeeded" if apptest_result else "Failed" | |
| 58 _logger.info("Completed: %s" % test_name) | |
| 59 if not apptest_result: | |
| 60 succeeded = False | |
| 61 return succeeded | |
| OLD | NEW |