| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** This file is sourced by unitest.dart. */ | 5 /** This file is sourced by unitest.dart. */ |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Hooks to configure the unittest library for different platforms. This class | 8 * Hooks to configure the unittest library for different platforms. This class |
| 9 * implements the API in a platform-independent way. Tests that want to take | 9 * implements the API in a platform-independent way. Tests that want to take |
| 10 * advantage of the platform can create a subclass and override methods from | 10 * advantage of the platform can create a subclass and override methods from |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Show the summary. | 57 // Show the summary. |
| 58 print(''); | 58 print(''); |
| 59 | 59 |
| 60 var success = false; | 60 var success = false; |
| 61 if (passed == 0 && failed == 0 && errors == 0) { | 61 if (passed == 0 && failed == 0 && errors == 0) { |
| 62 print('No tests found.'); | 62 print('No tests found.'); |
| 63 // This is considered a failure too: if this happens you probably have a | 63 // This is considered a failure too: if this happens you probably have a |
| 64 // bug in your unit tests. | 64 // bug in your unit tests, unless you are filtering. |
| 65 if (getFilter() != null) { |
| 66 success = true; |
| 67 } |
| 65 } else if (failed == 0 && errors == 0 && uncaughtError == null) { | 68 } else if (failed == 0 && errors == 0 && uncaughtError == null) { |
| 66 print('All $passed tests passed.'); | 69 print('All $passed tests passed.'); |
| 67 success = true; | 70 success = true; |
| 68 } else { | 71 } else { |
| 69 if (uncaughtError != null) { | 72 if (uncaughtError != null) { |
| 70 print('Top-level uncaught error: $uncaughtError'); | 73 print('Top-level uncaught error: $uncaughtError'); |
| 71 } | 74 } |
| 72 print('$passed PASSED, $failed FAILED, $errors ERRORS'); | 75 print('$passed PASSED, $failed FAILED, $errors ERRORS'); |
| 73 } | 76 } |
| 74 | 77 |
| 75 // An exception is used by the test infrastructure to detect failure. | 78 // An exception is used by the test infrastructure to detect failure. |
| 76 if (!success) throw new Exception("Some tests failed."); | 79 if (!success) throw new Exception("Some tests failed."); |
| 77 } | 80 } |
| 78 | 81 |
| 79 String _indent(String str) { | 82 String _indent(String str) { |
| 80 // TODO(nweiz): Use this simpler code once issue 2980 is fixed. | 83 // TODO(nweiz): Use this simpler code once issue 2980 is fixed. |
| 81 // return str.replaceAll(const RegExp("^", multiLine: true), " "); | 84 // return str.replaceAll(const RegExp("^", multiLine: true), " "); |
| 82 | 85 |
| 83 return Strings.join(str.split("\n").map((line) => " $line"), "\n"); | 86 return Strings.join(str.split("\n").map((line) => " $line"), "\n"); |
| 84 } | 87 } |
| 85 } | 88 } |
| OLD | NEW |