Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: dart/pkg/unittest/config.dart

Issue 10914197: Revert "Run dart2js tests unmodified in browser." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 19 matching lines...) Expand all
30 * even before tests are added to the test framework. It might be used to 30 * even before tests are added to the test framework. It might be used to
31 * determine/debug errors that occur before the test harness starts executing. 31 * determine/debug errors that occur before the test harness starts executing.
32 */ 32 */
33 void onInit() {} 33 void onInit() {}
34 34
35 /** 35 /**
36 * Called as soon as the unittest framework starts running. Used commonly to 36 * Called as soon as the unittest framework starts running. Used commonly to
37 * tell the vm or browser that tests are still running and the process should 37 * tell the vm or browser that tests are still running and the process should
38 * wait until they are done. 38 * wait until they are done.
39 */ 39 */
40 void onStart() { 40 void onStart() {}
41 _postMessage('unittest-suite-wait-for-done');
42 }
43 41
44 /** 42 /**
45 * Called when each test starts. Useful to show intermediate progress on 43 * Called when each test starts. Useful to show intermediate progress on
46 * a test suite. 44 * a test suite.
47 */ 45 */
48 void onTestStart(TestCase testCase) { 46 void onTestStart(TestCase testCase) {
49 currentTestCase = testCase; 47 currentTestCase = testCase;
50 } 48 }
51 49
52 /** 50 /**
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } else if (failed == 0 && errors == 0 && uncaughtError == null) { 114 } else if (failed == 0 && errors == 0 && uncaughtError == null) {
117 print('All $passed tests passed.'); 115 print('All $passed tests passed.');
118 success = true; 116 success = true;
119 } else { 117 } else {
120 if (uncaughtError != null) { 118 if (uncaughtError != null) {
121 print('Top-level uncaught error: $uncaughtError'); 119 print('Top-level uncaught error: $uncaughtError');
122 } 120 }
123 print('$passed PASSED, $failed FAILED, $errors ERRORS'); 121 print('$passed PASSED, $failed FAILED, $errors ERRORS');
124 } 122 }
125 123
126 if (success) { 124 // An exception is used by the test infrastructure to detect failure.
127 _postMessage('unittest-suite-success'); 125 if (!success) throw new Exception("Some tests failed.");
128 } else {
129 throw new Exception('Some tests failed.');
130 }
131 } 126 }
132 127
133 String _indent(String str) { 128 String _indent(String str) {
134 // TODO(nweiz): Use this simpler code once issue 2980 is fixed. 129 // TODO(nweiz): Use this simpler code once issue 2980 is fixed.
135 // return str.replaceAll(const RegExp("^", multiLine: true), " "); 130 // return str.replaceAll(const RegExp("^", multiLine: true), " ");
136 131
137 return Strings.join(str.split("\n").map((line) => " $line"), "\n"); 132 return Strings.join(str.split("\n").map((line) => " $line"), "\n");
138 } 133 }
139 134
140 /** Handle errors that happen outside the tests. */ 135 /** Handle errors that happen outside the tests. */
141 // TODO(vsm): figure out how to expose the stack trace here 136 // TODO(vsm): figure out how to expose the stack trace here
142 // Currently e.message works in dartium, but not in dartc. 137 // Currently e.message works in dartium, but not in dartc.
143 handleExternalError(e, String message) => 138 handleExternalError(e, String message) =>
144 _reportTestError('$message\nCaught $e', ''); 139 _reportTestError('$message\nCaught $e', '');
145
146 _postMessage(String message) {
147 // In dart2js browser tests, the JavaScript-based test controller
148 // intercepts calls to print and listens for "secret" messages.
149 print(message);
150 }
151 } 140 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/lib/isolate_patch.dart ('k') | dart/pkg/unittest/test_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698