| 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 /** | 5 /** |
| 6 * A unit test library for running groups of tests in a browser, instead of the | 6 * A unit test library for running groups of tests in a browser, instead of the |
| 7 * entire test file. This is especially used for large tests files that have | 7 * entire test file. This is especially used for large tests files that have |
| 8 * many subtests, so we can mark groups as failing at a finer granularity than | 8 * many subtests, so we can mark groups as failing at a finer granularity than |
| 9 * the entire test file. | 9 * the entire test file. |
| 10 * | 10 * |
| 11 * To use, import this file, and call [useHtmlIndividualConfiguration] at the | 11 * To use, import this file, and call [useHtmlIndividualConfiguration] at the |
| 12 * start of your set sequence. Your group descriptions MUST NOT contain spaces. | 12 * start of your set sequence. Important constraint: your group descriptions |
| 13 * MUST NOT contain spaces. |
| 13 */ | 14 */ |
| 14 #library('unittest'); | 15 #library('unittest'); |
| 15 | 16 |
| 16 #import('unittest.dart', prefix: 'unittest_file'); | 17 #import('unittest.dart', prefix: 'unittest'); |
| 17 #import('html_config.dart', prefix: 'htmlconfig'); | 18 #import('html_config.dart', prefix: 'htmlconfig'); |
| 18 #import('dart:html'); | 19 #import('dart:html'); |
| 19 | 20 |
| 20 class HtmlIndividualConfiguration extends htmlconfig.HtmlConfiguration { | 21 class HtmlIndividualConfiguration extends htmlconfig.HtmlConfiguration { |
| 21 | 22 |
| 22 String _noSuchTest = ''; | 23 String _noSuchTest = ''; |
| 23 HtmlIndividualConfiguration(isLayoutTest): super(isLayoutTest); | 24 HtmlIndividualConfiguration(isLayoutTest): super(isLayoutTest); |
| 24 | 25 |
| 25 void onStart() { | 26 void onStart() { |
| 26 var testName = window.location.hash; | 27 var testGroupName = window.location.hash; |
| 27 if (testName != '') { | 28 if (testGroupName != '') { |
| 28 try { | 29 try { |
| 29 testName = testName.substring(1); // cut off the # | 30 testGroupName = testGroupName.substring(1); // cut off the # |
| 30 unittest_file.filterTests('^$testName'); | 31 unittest.filterTests('^$testGroupName'); |
| 31 } catch (e) { | 32 } catch (e) { |
| 32 print('tried to match "$testName"'); | 33 print('tried to match "$testGroupName"'); |
| 33 for (TestCase c in unittest_file.testCases) | |
| 34 print('test case ${c.description}'); | |
| 35 print('NO_SUCH_TEST'); | 34 print('NO_SUCH_TEST'); |
| 36 exit(1); | 35 exit(1); |
| 37 } | 36 } |
| 38 } | 37 } |
| 39 super.onStart(); | 38 super.onStart(); |
| 40 } | 39 } |
| 41 } | 40 } |
| 42 | 41 |
| 43 void useHtmlIndividualConfiguration([bool isLayoutTest = false]) { | 42 void useHtmlIndividualConfiguration([bool isLayoutTest = false]) { |
| 44 unittest_file.configure(new HtmlIndividualConfiguration(isLayoutTest)); | 43 unittest.configure(new HtmlIndividualConfiguration(isLayoutTest)); |
| 45 } | 44 } |
| OLD | NEW |