Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 09a4f23

Browse files
authored
Prevent tests from producing dill files alongside the test file (#115075)
Fixes Dart-Code/Dart-Code#4243.
1 parent 5a60045 commit 09a4f23

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

packages/flutter_tools/lib/src/test/flutter_platform.dart

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,16 @@ class FlutterPlatform extends PlatformPlugin {
458458
controllerSinkClosed = true;
459459
}));
460460

461-
// When start paused is specified, it means that the user is likely
462-
// running this with a debugger attached. Initialize the resident
463-
// compiler in this case.
464-
if (debuggingOptions.startPaused) {
465-
compiler ??= TestCompiler(debuggingOptions.buildInfo, flutterProject, precompiledDillPath: precompiledDillPath, testTimeRecorder: testTimeRecorder);
466-
final Uri testUri = globals.fs.file(testPath).uri;
467-
// Trigger a compilation to initialize the resident compiler.
468-
unawaited(compiler!.compile(testUri));
461+
void initializeExpressionCompiler(String path) {
462+
// When start paused is specified, it means that the user is likely
463+
// running this with a debugger attached. Initialize the resident
464+
// compiler in this case.
465+
if (debuggingOptions.startPaused) {
466+
compiler ??= TestCompiler(debuggingOptions.buildInfo, flutterProject, precompiledDillPath: precompiledDillPath, testTimeRecorder: testTimeRecorder);
467+
final Uri uri = globals.fs.file(path).uri;
468+
// Trigger a compilation to initialize the resident compiler.
469+
unawaited(compiler!.compile(uri));
470+
}
469471
}
470472

471473
// If a kernel file is given, then use that to launch the test.
@@ -474,6 +476,7 @@ class FlutterPlatform extends PlatformPlugin {
474476
String? mainDart;
475477
if (precompiledDillPath != null) {
476478
mainDart = precompiledDillPath;
479+
initializeExpressionCompiler(testPath);
477480
} else if (precompiledDillFiles != null) {
478481
mainDart = precompiledDillFiles![testPath];
479482
} else {
@@ -489,6 +492,9 @@ class FlutterPlatform extends PlatformPlugin {
489492
testHarnessChannel.sink.addError('Compilation failed for testPath=$testPath');
490493
return null;
491494
}
495+
} else {
496+
// For integration tests, we may still need to set up expression compilation service.
497+
initializeExpressionCompiler(mainDart);
492498
}
493499
}
494500

packages/flutter_tools/test/integration.shard/expression_evaluation_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ void batch2() {
116116
);
117117
await flutter.waitForPause();
118118
await evaluateTrivialExpressions(flutter);
119+
120+
// Ensure we did not leave a dill file alongside the test.
121+
// https://github.com/Dart-Code/Dart-Code/issues/4243.
122+
final String dillFilename = '${project.testFilePath}.dill';
123+
expect(fileSystem.file(dillFilename).existsSync(), isFalse);
124+
119125
await cleanProject();
120126
});
121127

@@ -168,6 +174,12 @@ void batch3() {
168174
);
169175
await flutter.waitForPause();
170176
await evaluateTrivialExpressions(flutter);
177+
178+
// Ensure we did not leave a dill file alongside the test.
179+
// https://github.com/Dart-Code/Dart-Code/issues/4243.
180+
final String dillFilename = '${project.testFilePath}.dill';
181+
expect(fileSystem.file(dillFilename).existsSync(), isFalse);
182+
171183
await cleanProject();
172184
});
173185

0 commit comments

Comments
 (0)