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

Side by Side Diff: lib/vm_config.dart

Issue 934413002: Replace the existing unittest APIs with the new runner infrastructure. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Rebase Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /// A simple unit test library for running tests on the VM.
6 library unittest.vm_config; 5 library unittest.vm_config;
kevmoo 2015/02/19 23:13:19 Mark the library as deprecated – its lights up nic
7 6
8 import 'dart:async'; 7 import 'src/simple_configuration.dart';
9 import 'dart:io';
10 import 'unittest.dart';
11 8
9 /// This is a stub class used to preserve compatibility with unittest 0.11.*.
10 ///
11 /// It will be removed before the next version is released.
12 @deprecated
12 class VMConfiguration extends SimpleConfiguration { 13 class VMConfiguration extends SimpleConfiguration {
13 // Color constants used for generating messages.
14 final String GREEN_COLOR = '\u001b[32m'; 14 final String GREEN_COLOR = '\u001b[32m';
15 final String RED_COLOR = '\u001b[31m'; 15 final String RED_COLOR = '\u001b[31m';
16 final String MAGENTA_COLOR = '\u001b[35m'; 16 final String MAGENTA_COLOR = '\u001b[35m';
17 final String NO_COLOR = '\u001b[0m'; 17 final String NO_COLOR = '\u001b[0m';
18 18
19 // We make this public so the user can turn it off if they want. 19 bool useColor = false;
20 bool useColor;
21 20
22 VMConfiguration() 21 VMConfiguration() : super();
23 : super(),
24 useColor = stdioType(stdout) == StdioType.TERMINAL;
25
26 String formatResult(TestCase testCase) {
27 String result = super.formatResult(testCase);
28 if (useColor) {
29 if (testCase.result == PASS) {
30 return "${GREEN_COLOR}${result}${NO_COLOR}";
31 } else if (testCase.result == FAIL) {
32 return "${RED_COLOR}${result}${NO_COLOR}";
33 } else if (testCase.result == ERROR) {
34 return "${MAGENTA_COLOR}${result}${NO_COLOR}";
35 }
36 }
37 return result;
38 }
39
40 void onInit() {
41 super.onInit();
42 filterStacks = formatStacks = true;
43 }
44
45 void onDone(bool success) {
46 int status;
47 try {
48 super.onDone(success);
49 status = 0;
50 } catch (ex) {
51 // A non-zero exit code is used by the test infrastructure to detect
52 // failure.
53 status = 1;
54 }
55 Future.wait([stdout.close(), stderr.close()]).then((_) {
56 exit(status);
57 });
58 }
59 } 22 }
60 23
61 void useVMConfiguration() { 24 @deprecated
62 unittestConfiguration = _singleton; 25 void useVMConfiguration() {}
63 }
64
65 final _singleton = new VMConfiguration();
OLDNEW
« lib/src/test_case.dart ('K') | « lib/unittest.dart ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698