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

Unified Diff: pkg/scheduled_test/lib/scheduled_test.dart

Issue 13973021: Retrying the setUp/tearDown chaining change. This is the same as r21819 but with a change to schedu… (Closed) Base URL: http://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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/scheduled_test/test/scheduled_test/set_up_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/scheduled_test/lib/scheduled_test.dart
===================================================================
--- pkg/scheduled_test/lib/scheduled_test.dart (revision 21853)
+++ pkg/scheduled_test/lib/scheduled_test.dart (working copy)
@@ -258,10 +258,11 @@
/// Creates a new named group of tests. This has the same semantics as
/// [unittest.group].
void group(String description, void body()) {
+ _ensureInitialized();
+ _ensureSetUpForTopLevel();
unittest.group(description, () {
var wasInGroup = _inGroup;
_inGroup = true;
- _setUpScheduledTest();
body();
_inGroup = wasInGroup;
});
@@ -311,20 +312,39 @@
/// Registers callbacks for [unittest.setUp] and [unittest.tearDown] that set up
/// and tear down the scheduled test infrastructure.
void _setUpScheduledTest([void setUpFn()]) {
- if (!_inGroup) _setUpForTopLevel = true;
-
- unittest.setUp(() {
- if (currentSchedule != null) {
- throw new StateError('There seems to be another scheduled test '
- 'still running.');
- }
- _currentSchedule = new Schedule();
- _setUpFn = setUpFn;
- });
-
- unittest.tearDown(() {
- _currentSchedule = null;
- });
+ if (!_inGroup) {
+ _setUpForTopLevel = true;
+ unittest.setUp(() {
+ if (currentSchedule != null) {
+ throw new StateError('There seems to be another scheduled test '
+ 'still running.');
+ }
+ _currentSchedule = new Schedule();
+ if (_setUpFn != null) {
+ var parentFn = _setUpFn;
+ _setUpFn = () { parentFn(); setUpFn(); };
+ } else {
+ _setUpFn = setUpFn;
+ }
+ });
+
+ unittest.tearDown(() {
+ _currentSchedule = null;
+ _setUpFn = null;
+ });
+ } else {
+ unittest.setUp(() {
+ if (currentSchedule == null) {
+ throw new StateError('No schedule allocated.');
+ }
+ if (_setUpFn != null) {
nweiz 2013/04/23 20:50:43 Nit: it would be cleaner if this were "else if".
gram 2013/04/23 21:04:38 Done.
+ var parentFn = _setUpFn;
+ _setUpFn = () { parentFn(); setUpFn(); };
+ } else {
+ _setUpFn = setUpFn;
+ }
+ });
+ }
}
/// Ensures that the global configuration for `scheduled_test` has been
« no previous file with comments | « no previous file | pkg/scheduled_test/test/scheduled_test/set_up_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698