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

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

Issue 13539003: pkg/unittest: handling of runTests being called without any tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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) 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 library for writing dart unit tests. 6 * A library for writing dart unit tests.
7 * 7 *
8 * To import this library, install the 8 * To import this library, install the
9 * [unittest package](http://pub.dartlang.org/packages/unittest) via the pub 9 * [unittest package](http://pub.dartlang.org/packages/unittest) via the pub
10 * package manager. See the [Getting Started](http://pub.dartlang.org/doc) 10 * package manager. See the [Getting Started](http://pub.dartlang.org/doc)
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } else if (testFilter is RegExp) { 690 } else if (testFilter is RegExp) {
691 filterFunction = (t) => testFilter.hasMatch(t.description); 691 filterFunction = (t) => testFilter.hasMatch(t.description);
692 } else if (testFilter is Function) { 692 } else if (testFilter is Function) {
693 filterFunction = testFilter; 693 filterFunction = testFilter;
694 } 694 }
695 _testCases.retainWhere(filterFunction); 695 _testCases.retainWhere(filterFunction);
696 } 696 }
697 697
698 /** Runs all queued tests, one at a time. */ 698 /** Runs all queued tests, one at a time. */
699 void runTests() { 699 void runTests() {
700 _ensureInitialized(false);
700 _currentTestCaseIndex = 0; 701 _currentTestCaseIndex = 0;
701 _currentGroup = ''; 702 _currentGroup = '';
702 703
703 // If we are soloing a test, remove all the others. 704 // If we are soloing a test, remove all the others.
704 if (_soloTest != null) { 705 if (_soloTest != null) {
705 filterTests((t) => t == _soloTest); 706 filterTests((t) => t == _soloTest);
706 } 707 }
707 708
708 _config.onStart(); 709 _config.onStart();
709 710
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 799
799 String _fullSpec(String spec) { 800 String _fullSpec(String spec) {
800 if (spec == null) return '$_currentGroup'; 801 if (spec == null) return '$_currentGroup';
801 return _currentGroup != '' ? '$_currentGroup$groupSep$spec' : spec; 802 return _currentGroup != '' ? '$_currentGroup$groupSep$spec' : spec;
802 } 803 }
803 804
804 /** 805 /**
805 * Lazily initializes the test library if not already initialized. 806 * Lazily initializes the test library if not already initialized.
806 */ 807 */
807 void ensureInitialized() { 808 void ensureInitialized() {
809 _ensureInitialized(true);
810 }
811
812 void _ensureInitialized(bool configAutoStart) {
808 if (_initialized) { 813 if (_initialized) {
809 return; 814 return;
810 } 815 }
811 _initialized = true; 816 _initialized = true;
812 // Hook our async guard into the matcher library. 817 // Hook our async guard into the matcher library.
813 wrapAsync = (f, [id]) => expectAsync1(f, id: id); 818 wrapAsync = (f, [id]) => expectAsync1(f, id: id);
814 819
815 _uncaughtErrorMessage = null; 820 _uncaughtErrorMessage = null;
816 821
817 if (_config == null) { 822 if (_config == null) {
818 unittestConfiguration = new Configuration(); 823 unittestConfiguration = new Configuration();
819 } 824 }
820 _config.onInit(); 825 _config.onInit();
821 826
822 if (_config.autoStart) { 827 if (configAutoStart && _config.autoStart) {
823 // Immediately queue the suite up. It will run after a timeout (i.e. after 828 // Immediately queue the suite up. It will run after a timeout (i.e. after
824 // main() has returned). 829 // main() has returned).
825 _defer(runTests); 830 _defer(runTests);
826 } 831 }
827 } 832 }
828 833
829 /** Select a solo test by ID. */ 834 /** Select a solo test by ID. */
830 void setSoloTest(int id) { 835 void setSoloTest(int id) {
831 for (var i = 0; i < _testCases.length; i++) { 836 for (var i = 0; i < _testCases.length; i++) {
832 if (_testCases[i].id == id) { 837 if (_testCases[i].id == id) {
(...skipping 19 matching lines...) Expand all
852 } 857 }
853 858
854 /** Enable a test by ID. */ 859 /** Enable a test by ID. */
855 void enableTest(int testId) => _setTestEnabledState(testId, true); 860 void enableTest(int testId) => _setTestEnabledState(testId, true);
856 861
857 /** Disable a test by ID. */ 862 /** Disable a test by ID. */
858 void disableTest(int testId) => _setTestEnabledState(testId, false); 863 void disableTest(int testId) => _setTestEnabledState(testId, false);
859 864
860 /** Signature for a test function. */ 865 /** Signature for a test function. */
861 typedef dynamic TestFunction(); 866 typedef dynamic TestFunction();
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/test/unittest_test.dart » ('j') | pkg/unittest/test/unittest_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698