| 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 """Apptest is a Mojo application that interacts with another Mojo application | 5 """Apptest is a Mojo application that interacts with another Mojo application |
| 6 and verifies assumptions about behavior of the app being tested. | 6 and verifies assumptions about behavior of the app being tested. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 import logging | 9 import logging |
| 10 import time | 10 import time |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 the output indicates a successful run. | 46 the output indicates a successful run. |
| 47 | 47 |
| 48 Returns: | 48 Returns: |
| 49 True iff the test succeeded, False otherwise. | 49 True iff the test succeeded, False otherwise. |
| 50 """ | 50 """ |
| 51 arguments = _build_shell_arguments(shell_args, apptest_url, apptest_args) | 51 arguments = _build_shell_arguments(shell_args, apptest_url, apptest_args) |
| 52 command_line = "mojo_shell " + " ".join(["%r" % x for x in arguments]) | 52 command_line = "mojo_shell " + " ".join(["%r" % x for x in arguments]) |
| 53 | 53 |
| 54 _logger.debug("Starting: " + command_line) | 54 _logger.debug("Starting: " + command_line) |
| 55 start_time = time.time() | 55 start_time = time.time() |
| 56 (exit_code, output, did_time_out) = shell.RunAndGetOutput(arguments, timeout) | 56 (exit_code, output, did_time_out) = shell.run_and_get_output(arguments, |
| 57 timeout) |
| 57 run_time = time.time() - start_time | 58 run_time = time.time() - start_time |
| 58 _logger.debug("Completed: " + command_line) | 59 _logger.debug("Completed: " + command_line) |
| 59 | 60 |
| 60 # Only log if it took more than 3 second. | 61 # Only log if it took more than 3 second. |
| 61 if run_time >= 3: | 62 if run_time >= 3: |
| 62 _logger.info("Test took %.3f seconds: %s" % (run_time, command_line)) | 63 _logger.info("Test took %.3f seconds: %s" % (run_time, command_line)) |
| 63 | 64 |
| 64 if exit_code or did_time_out or not output_test(output): | 65 if exit_code or did_time_out or not output_test(output): |
| 65 print 'Failed test: %r' % command_line | 66 print 'Failed test: %r' % command_line |
| 66 if exit_code: | 67 if exit_code: |
| 67 print ' due to shell exit code %d' % exit_code | 68 print ' due to shell exit code %d' % exit_code |
| 68 elif did_time_out: | 69 elif did_time_out: |
| 69 print ' due to exceeded timeout of %fs' % timeout | 70 print ' due to exceeded timeout of %fs' % timeout |
| 70 else: | 71 else: |
| 71 print ' due to test results' | 72 print ' due to test results' |
| 72 print 72 * '-' | 73 print 72 * '-' |
| 73 print output | 74 print output |
| 74 print 72 * '-' | 75 print 72 * '-' |
| 75 return False | 76 return False |
| 76 return True | 77 return True |
| OLD | NEW |