[flutter_tools] warn when main library is relocated (#62930)
This commit is contained in:
parent
ef62463e9c
commit
762d9f7f4e
@ -376,10 +376,19 @@ class HotRunner extends ResidentRunner {
|
||||
asyncScanning: hotRunnerConfig.asyncScanning,
|
||||
packageConfig: flutterDevices[0].devFS.lastPackageConfig,
|
||||
);
|
||||
final File entrypointFile = globals.fs.file(mainPath);
|
||||
if (!entrypointFile.existsSync()) {
|
||||
globals.printError(
|
||||
'The entrypoint file (i.e. the file with main()) ${entrypointFile.path} '
|
||||
'cannot be found. Moving or renaming this file will prevent changes to '
|
||||
'its contents from being discovered during hot reload/restart until '
|
||||
'flutter is restarted or the file is restored.'
|
||||
);
|
||||
}
|
||||
final UpdateFSReport results = UpdateFSReport(success: true);
|
||||
for (final FlutterDevice device in flutterDevices) {
|
||||
results.incorporateResults(await device.updateDevFS(
|
||||
mainUri: globals.fs.file(mainPath).absolute.uri,
|
||||
mainUri: entrypointFile.absolute.uri,
|
||||
target: target,
|
||||
bundle: assetBundle,
|
||||
firstBuildTime: firstBuildTime,
|
||||
|
@ -609,6 +609,67 @@ void main() {
|
||||
Usage: () => MockUsage(),
|
||||
}));
|
||||
|
||||
testUsingContext('ResidentRunner reports error with missing entrypoint file', () => testbed.run(() async {
|
||||
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
|
||||
listViews,
|
||||
listViews,
|
||||
listViews,
|
||||
listViews,
|
||||
FakeVmServiceRequest(
|
||||
method: 'getIsolate',
|
||||
args: <String, Object>{
|
||||
'isolateId': '1',
|
||||
},
|
||||
jsonResponse: fakeUnpausedIsolate.toJson(),
|
||||
),
|
||||
FakeVmServiceRequest(
|
||||
method: 'ext.flutter.reassemble',
|
||||
args: <String, Object>{
|
||||
'isolateId': fakeUnpausedIsolate.id,
|
||||
},
|
||||
),
|
||||
]);
|
||||
when(mockDevice.sdkNameAndVersion).thenAnswer((Invocation invocation) async {
|
||||
return 'Example';
|
||||
});
|
||||
when(mockDevice.targetPlatform).thenAnswer((Invocation invocation) async {
|
||||
return TargetPlatform.android_arm;
|
||||
});
|
||||
when(mockDevice.isLocalEmulator).thenAnswer((Invocation invocation) async {
|
||||
return false;
|
||||
});
|
||||
final Completer<DebugConnectionInfo> onConnectionInfo = Completer<DebugConnectionInfo>.sync();
|
||||
final Completer<void> onAppStart = Completer<void>.sync();
|
||||
unawaited(residentRunner.attach(
|
||||
appStartedCompleter: onAppStart,
|
||||
connectionInfoCompleter: onConnectionInfo,
|
||||
));
|
||||
await onAppStart.future;
|
||||
when(mockFlutterDevice.updateDevFS(
|
||||
mainUri: anyNamed('mainUri'),
|
||||
target: anyNamed('target'),
|
||||
bundle: anyNamed('bundle'),
|
||||
firstBuildTime: anyNamed('firstBuildTime'),
|
||||
bundleFirstUpload: anyNamed('bundleFirstUpload'),
|
||||
bundleDirty: anyNamed('bundleDirty'),
|
||||
fullRestart: anyNamed('fullRestart'),
|
||||
projectRootPath: anyNamed('projectRootPath'),
|
||||
pathToReload: anyNamed('pathToReload'),
|
||||
invalidatedFiles: anyNamed('invalidatedFiles'),
|
||||
dillOutputPath: anyNamed('dillOutputPath'),
|
||||
packageConfig: anyNamed('packageConfig'),
|
||||
)).thenAnswer((Invocation invocation) async {
|
||||
return UpdateFSReport(success: true);
|
||||
});
|
||||
|
||||
final OperationResult result = await residentRunner.restart(fullRestart: false);
|
||||
|
||||
expect(globals.fs.file(globals.fs.path.join('lib', 'main.dart')), isNot(exists));
|
||||
expect(testLogger.errorText, contains('The entrypoint file (i.e. the file with main())'));
|
||||
expect(result.fatal, false);
|
||||
expect(result.code, 0);
|
||||
}));
|
||||
|
||||
|
||||
testUsingContext('ResidentRunner can send target platform to analytics from hot reload', () => testbed.run(() async {
|
||||
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[
|
||||
|
Loading…
x
Reference in New Issue
Block a user