| OLD | NEW |
| 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 /** | 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_vm_config; | 8 library unittest_vm_config; |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| 11 import 'dart:io'; | 11 import 'dart:io'; |
| 12 import 'unittest.dart'; | 12 import 'unittest.dart'; |
| 13 | 13 |
| 14 class VMConfiguration extends SimpleConfiguration { | 14 class VMConfiguration extends SimpleConfiguration { |
| 15 // Color constants used for generating messages. | 15 // Color constants used for generating messages. |
| 16 final String GREEN_COLOR = '\u001b[32m'; | 16 final String GREEN_COLOR = '\u001b[32m'; |
| 17 final String RED_COLOR = '\u001b[31m'; | 17 final String RED_COLOR = '\u001b[31m'; |
| 18 final String MAGENTA_COLOR = '\u001b[35m'; | 18 final String MAGENTA_COLOR = '\u001b[35m'; |
| 19 final String NO_COLOR = '\u001b[0m'; | 19 final String NO_COLOR = '\u001b[0m'; |
| 20 | 20 |
| 21 // We make this public so the user can turn it off if they want. | 21 // We make this public so the user can turn it off if they want. |
| 22 bool useColor; | 22 bool useColor; |
| 23 | 23 |
| 24 VMConfiguration() : | 24 VMConfiguration() |
| 25 super(), useColor = stdioType(stdout) == StdioType.TERMINAL; | 25 : super(), |
| 26 // TODO(nweiz): Re-enable this when issue 13712 is fixed. |
| 27 // useColor = stdioType(stdout) == StdioType.TERMINAL; |
| 28 useColor = false; |
| 26 | 29 |
| 27 String formatResult(TestCase testCase) { | 30 String formatResult(TestCase testCase) { |
| 28 String result = super.formatResult(testCase); | 31 String result = super.formatResult(testCase); |
| 29 if (useColor) { | 32 if (useColor) { |
| 30 if (testCase.result == PASS) { | 33 if (testCase.result == PASS) { |
| 31 return "${GREEN_COLOR}${result}${NO_COLOR}"; | 34 return "${GREEN_COLOR}${result}${NO_COLOR}"; |
| 32 } else if (testCase.result == FAIL) { | 35 } else if (testCase.result == FAIL) { |
| 33 return "${RED_COLOR}${result}${NO_COLOR}"; | 36 return "${RED_COLOR}${result}${NO_COLOR}"; |
| 34 } else if (testCase.result == ERROR) { | 37 } else if (testCase.result == ERROR) { |
| 35 return "${MAGENTA_COLOR}${result}${NO_COLOR}"; | 38 return "${MAGENTA_COLOR}${result}${NO_COLOR}"; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 57 exit(status); | 60 exit(status); |
| 58 }); | 61 }); |
| 59 } | 62 } |
| 60 } | 63 } |
| 61 | 64 |
| 62 void useVMConfiguration() { | 65 void useVMConfiguration() { |
| 63 unittestConfiguration = _singleton; | 66 unittestConfiguration = _singleton; |
| 64 } | 67 } |
| 65 | 68 |
| 66 final _singleton = new VMConfiguration(); | 69 final _singleton = new VMConfiguration(); |
| OLD | NEW |