[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>
This commit is contained in:
Jens Johansen 2021-05-26 12:33:52 +00:00 committed by commit-bot@chromium.org
parent 1d38c98b69
commit 57e467b6ee

View file

@ -18,7 +18,8 @@ import 'package:kernel/kernel.dart' show Component;
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 @@ main() async {
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 @@ class TestCompiler {
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 @@ class TestCompiler {
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 @@ class Generator {
return "// @dart = 2.9\n${beforePlug}${plug}${afterPlug}";
}
}
class CompilerAndOptions {
final TestCompiler compiler;
final CompilerOptions options;
CompilerAndOptions(this.compiler, this.options);
}