Prevent tests from producing dill files alongside the test file (#115075)

Fixes https://github.com/Dart-Code/Dart-Code/issues/4243.
This commit is contained in:
Danny Tuppeny 2022-11-10 20:00:19 +00:00 committed by GitHub
parent 5a600456b0
commit 09a4f23467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 8 deletions

View File

@ -458,14 +458,16 @@ class FlutterPlatform extends PlatformPlugin {
controllerSinkClosed = true; controllerSinkClosed = true;
})); }));
// When start paused is specified, it means that the user is likely void initializeExpressionCompiler(String path) {
// running this with a debugger attached. Initialize the resident // When start paused is specified, it means that the user is likely
// compiler in this case. // running this with a debugger attached. Initialize the resident
if (debuggingOptions.startPaused) { // compiler in this case.
compiler ??= TestCompiler(debuggingOptions.buildInfo, flutterProject, precompiledDillPath: precompiledDillPath, testTimeRecorder: testTimeRecorder); if (debuggingOptions.startPaused) {
final Uri testUri = globals.fs.file(testPath).uri; compiler ??= TestCompiler(debuggingOptions.buildInfo, flutterProject, precompiledDillPath: precompiledDillPath, testTimeRecorder: testTimeRecorder);
// Trigger a compilation to initialize the resident compiler. final Uri uri = globals.fs.file(path).uri;
unawaited(compiler!.compile(testUri)); // Trigger a compilation to initialize the resident compiler.
unawaited(compiler!.compile(uri));
}
} }
// If a kernel file is given, then use that to launch the test. // If a kernel file is given, then use that to launch the test.
@ -474,6 +476,7 @@ class FlutterPlatform extends PlatformPlugin {
String? mainDart; String? mainDart;
if (precompiledDillPath != null) { if (precompiledDillPath != null) {
mainDart = precompiledDillPath; mainDart = precompiledDillPath;
initializeExpressionCompiler(testPath);
} else if (precompiledDillFiles != null) { } else if (precompiledDillFiles != null) {
mainDart = precompiledDillFiles![testPath]; mainDart = precompiledDillFiles![testPath];
} else { } else {
@ -489,6 +492,9 @@ class FlutterPlatform extends PlatformPlugin {
testHarnessChannel.sink.addError('Compilation failed for testPath=$testPath'); testHarnessChannel.sink.addError('Compilation failed for testPath=$testPath');
return null; return null;
} }
} else {
// For integration tests, we may still need to set up expression compilation service.
initializeExpressionCompiler(mainDart);
} }
} }

View File

@ -116,6 +116,12 @@ void batch2() {
); );
await flutter.waitForPause(); await flutter.waitForPause();
await evaluateTrivialExpressions(flutter); await evaluateTrivialExpressions(flutter);
// Ensure we did not leave a dill file alongside the test.
// https://github.com/Dart-Code/Dart-Code/issues/4243.
final String dillFilename = '${project.testFilePath}.dill';
expect(fileSystem.file(dillFilename).existsSync(), isFalse);
await cleanProject(); await cleanProject();
}); });
@ -168,6 +174,12 @@ void batch3() {
); );
await flutter.waitForPause(); await flutter.waitForPause();
await evaluateTrivialExpressions(flutter); await evaluateTrivialExpressions(flutter);
// Ensure we did not leave a dill file alongside the test.
// https://github.com/Dart-Code/Dart-Code/issues/4243.
final String dillFilename = '${project.testFilePath}.dill';
expect(fileSystem.file(dillFilename).existsSync(), isFalse);
await cleanProject(); await cleanProject();
}); });