[CFE] Speedup test_generator_test by not verifying platform for every compile

Fixes https://github.com/dart-lang/sdk/issues/46088

Change-Id: Id46b06c90f68fa93300cbfbd8f4e0914e11abb35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201400
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
diff --git a/pkg/front_end/test/test_generator_test.dart b/pkg/front_end/test/test_generator_test.dart
index 449a33f..e08987a 100644
--- a/pkg/front_end/test/test_generator_test.dart
+++ b/pkg/front_end/test/test_generator_test.dart
@@ -18,7 +18,8 @@
 import 'incremental_suite.dart' as helper;
 
 main() async {
-  TestCompiler compiler = await TestCompiler.initialize();
+  CompilerAndOptions compilerAndOptions = TestCompiler.initialize();
+  TestCompiler compiler = compilerAndOptions.compiler;
   bool hasNewline = true;
   int numErrors = 0;
   List<String> errorSource = [];
@@ -31,6 +32,7 @@
         String source = outerContext
             .generate(innerContext.generate(expression.generate("")));
         String compileResult = await compiler.compile(source);
+        compilerAndOptions.options.skipPlatformVerification = true;
         if (compileResult != "") {
           if (!hasNewline) print("");
           hasNewline = true;
@@ -122,13 +124,13 @@
     return sb.toString();
   }
 
-  static Future<TestCompiler> initialize() async {
+  static CompilerAndOptions initialize() {
     final Uri base = Uri.parse("org-dartlang-test:///");
     final Uri sdkSummary = base.resolve("vm_platform_strong.dill");
     final Uri sdkRoot = computePlatformBinariesLocation(forceBuildDir: true);
     Uri platformUri = sdkRoot.resolve("vm_platform_strong.dill");
     final List<int> sdkSummaryData =
-        await new File.fromUri(platformUri).readAsBytes();
+        new File.fromUri(platformUri).readAsBytesSync();
     MemoryFileSystem fs = new MemoryFileSystem(base);
     fs.entityForUri(sdkSummary).writeAsBytesSync(sdkSummaryData);
 
@@ -169,8 +171,10 @@
     helper.TestIncrementalCompiler compiler =
         new helper.TestIncrementalCompiler(options, testUri);
 
-    return new TestCompiler._(testUri, fs, formattedErrors, formattedWarnings,
-        formattedErrorsCodes, formattedWarningsCodes, compiler);
+    return new CompilerAndOptions(
+        new TestCompiler._(testUri, fs, formattedErrors, formattedWarnings,
+            formattedErrorsCodes, formattedWarningsCodes, compiler),
+        options);
   }
 }
 
@@ -228,3 +232,10 @@
     return "// @dart = 2.9\n${beforePlug}${plug}${afterPlug}";
   }
 }
+
+class CompilerAndOptions {
+  final TestCompiler compiler;
+  final CompilerOptions options;
+
+  CompilerAndOptions(this.compiler, this.options);
+}