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

Unified Diff: pkg/analysis_server/test/reflective_tests.dart

Issue 362793004: Update analysis.errors notification to the newest spec. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | « pkg/analysis_server/test/operation/operation_analysis_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, []);
« no previous file with comments | « pkg/analysis_server/test/operation/operation_analysis_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698