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

Side by Side Diff: lib/unittest/unittest_vm.dart

Issue 10031022: step 1 in making unittest platform independent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 /** 5 /**
6 * A simple unit test library for running tests on the VM. 6 * A simple unit test library for running tests on the VM.
7 */ 7 */
8 #library('unittest'); 8 #library('unittest');
9 9
10 #import('dart:io'); 10 #import('dart:io');
11 #import('dart:isolate');
12
13 #source('config.dart');
11 #source('shared.dart'); 14 #source('shared.dart');
12 15
13 _platformInitialize() { 16 class PlatformConfiguration implements Configuration {
14 // Do nothing. 17 void onDone(int passed, int failed, int errors, List<TestCase> results) {
15 } 18 try {
16 19 super.onDone(passed, failed, errors, results);
17 _platformDefer(void callback()) { 20 } catch (Exception ex) {
18 new Timer(0, (timer) { 21 exit(1);
19 callback();
20 });
21 }
22
23 _platformStartTests() {
24 // Do nothing.
25 }
26
27 _platformCompleteTests(int testsPassed, int testsFailed, int testsErrors) {
28 // Print each test's result.
29 for (final test in _tests) {
30 print('${test.result.toUpperCase()}: ${test.description}');
31
32 if (test.message != '') {
33 print(' ${test.message}');
34 } 22 }
35 } 23 }
36
37 // Show the summary.
38 print('');
39
40 var success = false;
41 if (testsPassed == 0 && testsFailed == 0 && testsErrors == 0) {
42 print('No tests found.');
43 // This is considered a failure too: if this happens you probably have a
44 // bug in your unit tests.
45 } else if (testsFailed == 0 && testsErrors == 0) {
46 print('All $testsPassed tests passed.');
47 success = true;
48 } else {
49 print('$testsPassed PASSED, $testsFailed FAILED, $testsErrors ERRORS');
50 }
51
52 // A non-zero exit code is used by the test infrastructure to detect failure.
53 if (!success) exit(1);
54 } 24 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698