| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Apptest runner specific to the particular Dart apptest framework in | 5 """Apptest runner specific to the particular Dart apptest framework in |
| 6 /mojo/dart/apptests, built on top of the general apptest runner.""" | 6 /mojo/dart/apptests, built on top of the general apptest runner.""" |
| 7 | 7 |
| 8 import logging | 8 import logging |
| 9 import re | 9 import re |
| 10 | 10 |
| 11 _logging = logging.getLogger() | 11 _logging = logging.getLogger() |
| 12 | 12 |
| 13 from devtoolslib.apptest import run_apptest | 13 from devtoolslib.apptest import run_apptest |
| 14 | 14 |
| 15 SUCCESS_PATTERN = re.compile('^.+ .+: All tests passed!', re.MULTILINE) | 15 # The apptest framework guarantees that tearDownAll() is the last thing to be |
| 16 # called before the shell is terminated. Note that the shell may be terminated |
| 17 # before the "All tests passed!" string. |
| 18 # |
| 19 # So we pass on messages like: |
| 20 # 00:01 +3: (tearDownAll) |
| 21 # And fail on messages like: |
| 22 # 00:01 +2 -1: (tearDownAll) |
| 23 SUCCESS_PATTERN = re.compile(r'^\S+ \S+: \(tearDownAll\)', re.MULTILINE) |
| 16 | 24 |
| 17 | 25 |
| 18 def _dart_apptest_output_test(output): | 26 def _dart_apptest_output_test(output): |
| 19 return SUCCESS_PATTERN.search(output) is not None | 27 return SUCCESS_PATTERN.search(output) is not None |
| 20 | 28 |
| 21 | 29 |
| 22 # TODO(erg): Support android, launched services and fixture isolation. | 30 # TODO(erg): Support android, launched services and fixture isolation. |
| 23 def run_dart_apptest(shell, shell_args, apptest_url, apptest_args, timeout): | 31 def run_dart_apptest(shell, shell_args, apptest_url, apptest_args, timeout): |
| 24 """Runs a dart apptest. | 32 """Runs a dart apptest. |
| 25 | 33 |
| 26 Args: | 34 Args: |
| 27 shell_args: The arguments for mojo_shell. | 35 shell_args: The arguments for mojo_shell. |
| 28 apptest_url: Url of the apptest app to run. | 36 apptest_url: Url of the apptest app to run. |
| 29 apptest_args: Parameters to be passed to the apptest app. | 37 apptest_args: Parameters to be passed to the apptest app. |
| 30 | 38 |
| 31 Returns: | 39 Returns: |
| 32 True iff the test succeeded, False otherwise. | 40 True iff the test succeeded, False otherwise. |
| 33 """ | 41 """ |
| 34 return run_apptest(shell, shell_args, apptest_url, apptest_args, timeout, | 42 return run_apptest(shell, shell_args, apptest_url, apptest_args, timeout, |
| 35 _dart_apptest_output_test) | 43 _dart_apptest_output_test) |
| OLD | NEW |