| Index: pkg/analysis_server/test/reflective_tests.dart
|
| diff --git a/pkg/analysis_server/test/reflective_tests.dart b/pkg/analysis_server/test/reflective_tests.dart
|
| index 622ab5fe6e58a81493065ee309897935ede5ee06..5cfef6af8a66b75d7c21f0fd4faf0513c5454c01 100644
|
| --- a/pkg/analysis_server/test/reflective_tests.dart
|
| +++ b/pkg/analysis_server/test/reflective_tests.dart
|
| @@ -63,21 +63,34 @@ void runReflectiveTests(Type type) {
|
| });
|
| }
|
|
|
| +
|
| _runTest(ClassMirror classMirror, Symbol symbol) {
|
| InstanceMirror instanceMirror = classMirror.newInstance(new Symbol(''), []);
|
| + bool shouldRunTearDown = true;
|
| _invokeSymbolIfExists(instanceMirror, #setUp);
|
| - var testReturn = instanceMirror.invoke(symbol, []).reflectee;
|
| - if (testReturn is Future) {
|
| - return testReturn.whenComplete(() {
|
| - _invokeSymbolIfExists(instanceMirror, #tearDown);
|
| - });
|
| - } else {
|
| - _invokeSymbolIfExists(instanceMirror, #tearDown);
|
| - return testReturn;
|
| + try {
|
| + var testReturn = instanceMirror.invoke(symbol, []).reflectee;
|
| + if (testReturn is Future) {
|
| + shouldRunTearDown = false;
|
| + return testReturn.whenComplete(() {
|
| + _invokeTearDown(instanceMirror);
|
| + });
|
| + } else {
|
| + return testReturn;
|
| + }
|
| + } finally {
|
| + if (shouldRunTearDown) {
|
| + _invokeTearDown(instanceMirror);
|
| + }
|
| }
|
| }
|
|
|
|
|
| +void _invokeTearDown(InstanceMirror instanceMirror) {
|
| + _invokeSymbolIfExists(instanceMirror, #tearDown);
|
| +}
|
| +
|
| +
|
| void _invokeSymbolIfExists(InstanceMirror instanceMirror, Symbol symbol) {
|
| try {
|
| instanceMirror.invoke(symbol, []);
|
|
|