Add --frontend-server-starter-path option to flutter run and flutter test (#135038)
This commit is contained in:
@@ -175,6 +175,7 @@ void main() {
|
||||
dartDefines: <String>['foo=2', 'bar=2'],
|
||||
dartObfuscation: true,
|
||||
splitDebugInfoPath: 'foo/',
|
||||
frontendServerStarterPath: 'foo/bar/frontend_server_starter.dart',
|
||||
extraFrontEndOptions: <String>['--enable-experiment=non-nullable', 'bar'],
|
||||
extraGenSnapshotOptions: <String>['--enable-experiment=non-nullable', 'fizz'],
|
||||
bundleSkSLPath: 'foo/bar/baz.sksl.json',
|
||||
@@ -190,6 +191,7 @@ void main() {
|
||||
'BuildMode': 'debug',
|
||||
'DartDefines': 'Zm9vPTI=,YmFyPTI=',
|
||||
'DartObfuscation': 'true',
|
||||
'FrontendServerStarterPath': 'foo/bar/frontend_server_starter.dart',
|
||||
'ExtraFrontEndOptions': '--enable-experiment=non-nullable,bar',
|
||||
'ExtraGenSnapshotOptions': '--enable-experiment=non-nullable,fizz',
|
||||
'SplitDebugInfo': 'foo/',
|
||||
@@ -211,6 +213,7 @@ void main() {
|
||||
dartDefines: <String>['foo=2', 'bar=2'],
|
||||
dartObfuscation: true,
|
||||
splitDebugInfoPath: 'foo/',
|
||||
frontendServerStarterPath: 'foo/bar/frontend_server_starter.dart',
|
||||
extraFrontEndOptions: <String>['--enable-experiment=non-nullable', 'bar'],
|
||||
extraGenSnapshotOptions: <String>['--enable-experiment=non-nullable', 'fizz'],
|
||||
bundleSkSLPath: 'foo/bar/baz.sksl.json',
|
||||
@@ -226,6 +229,7 @@ void main() {
|
||||
'DART_DEFINES': 'Zm9vPTI=,YmFyPTI=',
|
||||
'DART_OBFUSCATION': 'true',
|
||||
'SPLIT_DEBUG_INFO': 'foo/',
|
||||
'FRONTEND_SERVER_STARTER_PATH': 'foo/bar/frontend_server_starter.dart',
|
||||
'EXTRA_FRONT_END_OPTIONS': '--enable-experiment=non-nullable,bar',
|
||||
'EXTRA_GEN_SNAPSHOT_OPTIONS': '--enable-experiment=non-nullable,fizz',
|
||||
'BUNDLE_SKSL_PATH': 'foo/bar/baz.sksl.json',
|
||||
@@ -242,6 +246,7 @@ void main() {
|
||||
dartDefineConfigJsonMap: <String, Object>{'baz': '2'},
|
||||
dartObfuscation: true,
|
||||
splitDebugInfoPath: 'foo/',
|
||||
frontendServerStarterPath: 'foo/bar/frontend_server_starter.dart',
|
||||
extraFrontEndOptions: <String>['--enable-experiment=non-nullable', 'bar'],
|
||||
extraGenSnapshotOptions: <String>['--enable-experiment=non-nullable', 'fizz'],
|
||||
bundleSkSLPath: 'foo/bar/baz.sksl.json',
|
||||
@@ -253,6 +258,7 @@ void main() {
|
||||
expect(buildInfo.toGradleConfig(), <String>[
|
||||
'-Pdart-defines=Zm9vPTI=,YmFyPTI=',
|
||||
'-Pdart-obfuscation=true',
|
||||
'-Pfrontend-server-starter-path=foo/bar/frontend_server_starter.dart',
|
||||
'-Pextra-front-end-options=--enable-experiment=non-nullable,bar',
|
||||
'-Pextra-gen-snapshot-options=--enable-experiment=non-nullable,fizz',
|
||||
'-Psplit-debug-info=foo/',
|
||||
|
||||
@@ -217,6 +217,53 @@ native-assets: {}
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
});
|
||||
|
||||
testWithoutContext('KernelSnapshot correctly forwards FrontendServerStarterPath', () async {
|
||||
fileSystem.file('.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('{"configVersion": 2, "packages":[]}');
|
||||
androidEnvironment.buildDir.childFile('native_assets.yaml')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(emptyNativeAssets);
|
||||
final String build = androidEnvironment.buildDir.path;
|
||||
final String flutterPatchedSdkPath = artifacts.getArtifactPath(
|
||||
Artifact.flutterPatchedSdkPath,
|
||||
platform: TargetPlatform.android_arm,
|
||||
mode: BuildMode.profile,
|
||||
);
|
||||
processManager.addCommands(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
'--disable-dart-dev',
|
||||
'path/to/frontend_server_starter.dart',
|
||||
'--sdk-root',
|
||||
'$flutterPatchedSdkPath/',
|
||||
'--target=flutter',
|
||||
'--no-print-incremental-dependencies',
|
||||
...buildModeOptions(BuildMode.profile, <String>[]),
|
||||
'--track-widget-creation',
|
||||
'--aot',
|
||||
'--tfa',
|
||||
'--target-os',
|
||||
'android',
|
||||
'--packages',
|
||||
'/.dart_tool/package_config.json',
|
||||
'--output-dill',
|
||||
'$build/app.dill',
|
||||
'--depfile',
|
||||
'$build/kernel_snapshot.d',
|
||||
'--native-assets',
|
||||
'$build/native_assets.yaml',
|
||||
'--verbosity=error',
|
||||
'file:///lib/main.dart',
|
||||
], stdout: 'result $kBoundaryKey\n$kBoundaryKey\n$kBoundaryKey $build/app.dill 0\n'),
|
||||
]);
|
||||
|
||||
await const KernelSnapshot()
|
||||
.build(androidEnvironment..defines[kFrontendServerStarterPath] = 'path/to/frontend_server_starter.dart');
|
||||
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
});
|
||||
|
||||
testWithoutContext('KernelSnapshot correctly forwards ExtraFrontEndOptions', () async {
|
||||
fileSystem.file('.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
|
||||
@@ -391,6 +391,38 @@ void main() {
|
||||
ProcessManager: () => processManager,
|
||||
}));
|
||||
|
||||
test('Dart2JSTarget ignores frontend server starter path option when calling dart2js', () => testbed.run(() async {
|
||||
environment.defines[kBuildMode] = 'profile';
|
||||
environment.defines[kFrontendServerStarterPath] = 'path/to/frontend_server_starter.dart';
|
||||
processManager.addCommand(FakeCommand(
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'--no-source-maps',
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
'--packages=.dart_tool/package_config.json',
|
||||
'--cfe-only',
|
||||
environment.buildDir.childFile('main.dart').absolute.path,
|
||||
]
|
||||
));
|
||||
processManager.addCommand(FakeCommand(
|
||||
command: <String>[
|
||||
..._kDart2jsLinuxArgs,
|
||||
'-Ddart.vm.profile=true',
|
||||
'--no-minify',
|
||||
'--no-source-maps',
|
||||
'-O4',
|
||||
'-o',
|
||||
environment.buildDir.childFile('main.dart.js').absolute.path,
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
]
|
||||
));
|
||||
|
||||
await Dart2JSTarget(WebRendererMode.auto).build(environment);
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => processManager,
|
||||
}));
|
||||
|
||||
test('Dart2JSTarget calls dart2js with expected args with enabled experiment', () => testbed.run(() async {
|
||||
environment.defines[kBuildMode] = 'profile';
|
||||
|
||||
@@ -87,6 +87,7 @@ void main() {
|
||||
BuildMode.debug,
|
||||
null,
|
||||
trackWidgetCreation: true,
|
||||
frontendServerStarterPath: 'path/to/frontend_server_starter.dart',
|
||||
extraFrontEndOptions: <String>['test1', 'test2'],
|
||||
extraGenSnapshotOptions: <String>['test3', 'test4'],
|
||||
fileSystemRoots: <String>['test5', 'test6'],
|
||||
@@ -106,6 +107,7 @@ void main() {
|
||||
expect(env!.defines[kTargetPlatform], 'ios');
|
||||
expect(env!.defines[kTargetFile], mainPath);
|
||||
expect(env!.defines[kTrackWidgetCreation], 'true');
|
||||
expect(env!.defines[kFrontendServerStarterPath], 'path/to/frontend_server_starter.dart');
|
||||
expect(env!.defines[kExtraFrontEndOptions], 'test1,test2');
|
||||
expect(env!.defines[kExtraGenSnapshotOptions], 'test3,test4');
|
||||
expect(env!.defines[kFileSystemRoots], 'test5,test6');
|
||||
|
||||
@@ -1963,6 +1963,28 @@ flutter:
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('FlutterDevice passes frontendServerStarterPath parameter if specified', () async {
|
||||
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
|
||||
final FakeDevice device = FakeDevice();
|
||||
|
||||
final DefaultResidentCompiler? residentCompiler = (await FlutterDevice.create(
|
||||
device,
|
||||
buildInfo: const BuildInfo(
|
||||
BuildMode.debug,
|
||||
'',
|
||||
treeShakeIcons: false,
|
||||
frontendServerStarterPath: '/foo/bar/frontend_server_starter.dart',
|
||||
),
|
||||
target: null, platform: FakePlatform(),
|
||||
)).generator as DefaultResidentCompiler?;
|
||||
|
||||
expect(residentCompiler!.frontendServerStarterPath, '/foo/bar/frontend_server_starter.dart');
|
||||
}, overrides: <Type, Generator>{
|
||||
Artifacts: () => Artifacts.test(),
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
|
||||
testUsingContext('Handle existing VM service clients DDS error', () => testbed.run(() async {
|
||||
fakeVmServiceHost = FakeVmServiceHost(requests: <VmServiceExpectation>[]);
|
||||
final FakeDevice device = FakeDevice()
|
||||
|
||||
@@ -51,6 +51,7 @@ void main() {
|
||||
'-dTrackWidgetCreation=',
|
||||
'-dDartObfuscation=',
|
||||
'-dAction=build',
|
||||
'-dFrontendServerStarterPath=',
|
||||
'--ExtraGenSnapshotOptions=',
|
||||
'--DartDefines=',
|
||||
'--ExtraFrontEndOptions=',
|
||||
@@ -103,6 +104,7 @@ void main() {
|
||||
'-dTrackWidgetCreation=',
|
||||
'-dDartObfuscation=',
|
||||
'-dAction=',
|
||||
'-dFrontendServerStarterPath=',
|
||||
'--ExtraGenSnapshotOptions=',
|
||||
'--DartDefines=',
|
||||
'--ExtraFrontEndOptions=',
|
||||
@@ -136,6 +138,7 @@ void main() {
|
||||
const String expandedCodeSignIdentity = 'F1326572E0B71C3C8442805230CB4B33B708A2E2';
|
||||
const String extraFrontEndOptions = '--some-option';
|
||||
const String extraGenSnapshotOptions = '--obfuscate';
|
||||
const String frontendServerStarterPath = '/path/to/frontend_server_starter.dart';
|
||||
const String sdkRoot = '/path/to/sdk';
|
||||
const String splitDebugInfo = '/path/to/split/debug/info';
|
||||
const String trackWidgetCreation = 'true';
|
||||
@@ -154,6 +157,7 @@ void main() {
|
||||
'EXTRA_FRONT_END_OPTIONS': extraFrontEndOptions,
|
||||
'EXTRA_GEN_SNAPSHOT_OPTIONS': extraGenSnapshotOptions,
|
||||
'FLUTTER_ROOT': flutterRoot.path,
|
||||
'FRONTEND_SERVER_STARTER_PATH': frontendServerStarterPath,
|
||||
'INFOPLIST_PATH': 'Info.plist',
|
||||
'SDKROOT': sdkRoot,
|
||||
'SPLIT_DEBUG_INFO': splitDebugInfo,
|
||||
@@ -177,6 +181,7 @@ void main() {
|
||||
'-dTrackWidgetCreation=$trackWidgetCreation',
|
||||
'-dDartObfuscation=$dartObfuscation',
|
||||
'-dAction=install',
|
||||
'-dFrontendServerStarterPath=$frontendServerStarterPath',
|
||||
'--ExtraGenSnapshotOptions=$extraGenSnapshotOptions',
|
||||
'--DartDefines=$dartDefines',
|
||||
'--ExtraFrontEndOptions=$extraFrontEndOptions',
|
||||
|
||||
Reference in New Issue
Block a user