Follow up to previous CL
This addresses comments from
https://dart-review.googlesource.com/c/sdk/+/58201.
Change-Id: I59fd5ea06fbd644a7ba5e6be842ce20cfaee7536
Reviewed-on: https://dart-review.googlesource.com/59060
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Peter von der Ahé <ahe@google.com>
diff --git a/pkg/analyzer/test/generated/parser_forest_test.dart b/pkg/analyzer/test/generated/parser_forest_test.dart
index ed65757..dfeda9f 100644
--- a/pkg/analyzer/test/generated/parser_forest_test.dart
+++ b/pkg/analyzer/test/generated/parser_forest_test.dart
@@ -8,8 +8,8 @@
import '../src/fasta/body_builder_test_helper.dart';
import 'parser_test.dart';
-main() async {
- await CompilerTestContext.runWithTestOptions((_) {
+main() {
+ return CompilerTestContext.runWithTestOptions((_) {
defineReflectiveSuite(() {
defineReflectiveTests(ClassMemberParserTest_Forest);
defineReflectiveTests(ComplexParserTest_Forest);
diff --git a/pkg/analyzer/test/src/fasta/body_builder_test_helper.dart b/pkg/analyzer/test/src/fasta/body_builder_test_helper.dart
index 64569c3..66b2d52 100644
--- a/pkg/analyzer/test/src/fasta/body_builder_test_helper.dart
+++ b/pkg/analyzer/test/src/fasta/body_builder_test_helper.dart
@@ -145,6 +145,13 @@
T result;
Completer<T> completer = new Completer<T>();
+ // Since we're using `package:test_reflective_loader`, we can't rely on
+ // normal async behavior, as `defineReflectiveSuite` doesn't return a
+ // future. However, since it's built on top of `package:test`, we can
+ // obtain a future that completes when all the tests are done using
+ // `tearDownAll`. This allows this function to complete no earlier than
+ // when the tests are done. This is important, as we don't want to call
+ // `CompilerContext.clear` before then.
tearDownAll(() => completer.complete(result));
result = await action(c);
return completer.future;
diff --git a/pkg/analyzer/test/src/fasta/resolution_test.dart b/pkg/analyzer/test/src/fasta/resolution_test.dart
index 9105bf8..1fbaa11 100644
--- a/pkg/analyzer/test/src/fasta/resolution_test.dart
+++ b/pkg/analyzer/test/src/fasta/resolution_test.dart
@@ -10,8 +10,8 @@
import '../../generated/parser_test.dart';
import 'body_builder_test_helper.dart';
-main() async {
- await CompilerTestContext.runWithTestOptions((_) {
+main() {
+ return CompilerTestContext.runWithTestOptions((_) {
defineReflectiveSuite(() {
defineReflectiveTests(ResolutionTest);
});