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

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

Issue 495813002: Fix memory leak in unittest - the testCases variable doesn't release the (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | pkg/unittest/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of unittest; 5 part of unittest;
6 6
7 /// Represents the state for an individual unit test. 7 /// Represents the state for an individual unit test.
8 /// 8 ///
9 /// Create by calling [test] or [solo_test]. 9 /// Create by calling [test] or [solo_test].
10 class TestCase { 10 class TestCase {
11 /// Identifier for this test. 11 /// Identifier for this test.
12 final int id; 12 final int id;
13 13
14 /// A description of what the test is specifying. 14 /// A description of what the test is specifying.
15 final String description; 15 final String description;
16 16
17 /// The setup function to call before the test, if any. 17 /// The setup function to call before the test, if any.
18 final Function _setUp; 18 Function _setUp;
19 19
20 /// The teardown function to call after the test, if any. 20 /// The teardown function to call after the test, if any.
21 final Function _tearDown; 21 Function _tearDown;
22 22
23 /// The body of the test case. 23 /// The body of the test case.
24 final TestFunction _testFunction; 24 TestFunction _testFunction;
25 25
26 /// Remaining number of callbacks functions that must reach a 'done' state 26 /// Remaining number of callbacks functions that must reach a 'done' state
27 /// to wait for before the test completes. 27 /// to wait for before the test completes.
28 int _callbackFunctionsOutstanding = 0; 28 int _callbackFunctionsOutstanding = 0;
29 29
30 String _message = ''; 30 String _message = '';
31 /// Error or failure message. 31 /// Error or failure message.
32 String get message => _message; 32 String get message => _message;
33 33
34 String _result; 34 String _result;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // Outstanding callbacks exist; we need to return a Future. 113 // Outstanding callbacks exist; we need to return a Future.
114 _testComplete = new Completer(); 114 _testComplete = new Completer();
115 return _testComplete.future.whenComplete(() { 115 return _testComplete.future.whenComplete(() {
116 if (_tearDown != null) { 116 if (_tearDown != null) {
117 return _tearDown(); 117 return _tearDown();
118 } 118 }
119 }).catchError(_errorHandler('Teardown')); 119 }).catchError(_errorHandler('Teardown'));
120 } else if (_tearDown != null) { 120 } else if (_tearDown != null) {
121 return _tearDown(); 121 return _tearDown();
122 } 122 }
123 }).catchError(_errorHandler('Teardown')); 123 }).catchError(_errorHandler('Teardown')).whenComplete(() {
124 _setUp = null;
125 _tearDown = null;
126 _testFunction = null;
127 });
124 } 128 }
125 129
126 // Set the results, notify the config, and return true if this 130 // Set the results, notify the config, and return true if this
127 // is the first time the result is being set. 131 // is the first time the result is being set.
128 void _setResult(String testResult, String messageText, StackTrace stack) { 132 void _setResult(String testResult, String messageText, StackTrace stack) {
129 _message = messageText; 133 _message = messageText;
130 _stackTrace = getTrace(stack, formatStacks, filterStacks); 134 _stackTrace = getTrace(stack, formatStacks, filterStacks);
131 if (_stackTrace == null) _stackTrace = stack; 135 if (_stackTrace == null) _stackTrace = stack;
132 if (result == null) { 136 if (result == null) {
133 _result = testResult; 137 _result = testResult;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 182 }
179 183
180 void _markCallbackComplete() { 184 void _markCallbackComplete() {
181 if (--_callbackFunctionsOutstanding == 0 && !isComplete) { 185 if (--_callbackFunctionsOutstanding == 0 && !isComplete) {
182 _pass(); 186 _pass();
183 } 187 }
184 } 188 }
185 189
186 String toString() => _result != null ? "$description: $result" : description; 190 String toString() => _result != null ? "$description: $result" : description;
187 } 191 }
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698