[Reland] Skip injecting Bonjour settings when port publication is disabled (#136842)
Reland https://github.com/flutter/flutter/pull/136751 with fixes.
This commit is contained in:
committed by
GitHub
parent
9fa9fd365c
commit
3c3d414e7c
@@ -146,6 +146,7 @@ void main() {
|
||||
bool verbose = false,
|
||||
bool simulator = false,
|
||||
bool customNaming = false,
|
||||
bool disablePortPublication = false,
|
||||
String? deviceId,
|
||||
int exitCode = 0,
|
||||
String? stdout,
|
||||
@@ -189,6 +190,8 @@ void main() {
|
||||
],
|
||||
'-resultBundlePath', _xcBundleDirectoryPath,
|
||||
'-resultBundleVersion', '3',
|
||||
if (disablePortPublication)
|
||||
'DISABLE_PORT_PUBLICATION=YES',
|
||||
'FLUTTER_SUPPRESS_ANALYTICS=true',
|
||||
'COMPILER_INDEX_STORE_ENABLE=NO',
|
||||
],
|
||||
@@ -303,6 +306,69 @@ void main() {
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
});
|
||||
|
||||
testUsingContext('ios build invokes xcode build with disable port publication setting', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
androidSdk: FakeAndroidSdk(),
|
||||
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
|
||||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
processUtils: processUtils,
|
||||
osUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
createMinimalMockProjectFiles();
|
||||
|
||||
await createTestCommandRunner(command).run(
|
||||
const <String>['build', 'ios', '--no-pub', '--no-publish-port', '--ci']
|
||||
);
|
||||
expect(testLogger.statusText, contains('build/ios/iphoneos/Runner.app'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
|
||||
xattrCommand,
|
||||
setUpFakeXcodeBuildHandler(
|
||||
disablePortPublication: true,
|
||||
onRun: () {
|
||||
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
|
||||
},
|
||||
),
|
||||
setUpRsyncCommand(),
|
||||
]),
|
||||
Platform: () => macosPlatform,
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
});
|
||||
|
||||
testUsingContext('ios build invokes xcode build without disable port publication setting when not in CI', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
androidSdk: FakeAndroidSdk(),
|
||||
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
|
||||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
processUtils: processUtils,
|
||||
osUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
createMinimalMockProjectFiles();
|
||||
|
||||
await createTestCommandRunner(command).run(
|
||||
const <String>['build', 'ios', '--no-pub', '--no-publish-port']
|
||||
);
|
||||
expect(testLogger.statusText, contains('build/ios/iphoneos/Runner.app'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
|
||||
xattrCommand,
|
||||
setUpFakeXcodeBuildHandler(
|
||||
onRun: () {
|
||||
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
|
||||
},
|
||||
),
|
||||
setUpRsyncCommand(),
|
||||
]),
|
||||
Platform: () => macosPlatform,
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
});
|
||||
|
||||
testUsingContext('ios build invokes xcode build with renamed xcodeproj and xcworkspace', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
|
||||
@@ -604,6 +604,34 @@ void main() {
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
});
|
||||
|
||||
testUsingContext('ipa build invokes xcode build without disablePortPublication', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
androidSdk: FakeAndroidSdk(),
|
||||
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
|
||||
logger: logger,
|
||||
fileSystem: fileSystem,
|
||||
processUtils: processUtils,
|
||||
osUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
fakeProcessManager.addCommands(<FakeCommand>[
|
||||
xattrCommand,
|
||||
setUpFakeXcodeBuildHandler(),
|
||||
exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist),
|
||||
]);
|
||||
createMinimalMockProjectFiles();
|
||||
|
||||
await createTestCommandRunner(command).run(
|
||||
const <String>['build', 'ipa', '--no-pub', '--ci']
|
||||
);
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => fakeProcessManager,
|
||||
Platform: () => macosPlatform,
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
});
|
||||
|
||||
testUsingContext('ipa build --no-codesign skips codesigning and IPA creation', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
|
||||
@@ -183,5 +183,30 @@ void main() {
|
||||
''');
|
||||
expect(result, const ProcessResultMatcher());
|
||||
});
|
||||
|
||||
test('does not add bonjour settings when port publication is disabled', () async {
|
||||
infoPlist.writeAsStringSync('''
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
</dict>
|
||||
</plist>''');
|
||||
|
||||
final ProcessResult result = await Process.run(
|
||||
xcodeBackendPath,
|
||||
<String>['test_vm_service_bonjour_service'],
|
||||
environment: <String, String>{
|
||||
'CONFIGURATION': 'Debug',
|
||||
'BUILT_PRODUCTS_DIR': buildDirectory.path,
|
||||
'INFOPLIST_PATH': 'Info.plist',
|
||||
'DISABLE_PORT_PUBLICATION': 'YES',
|
||||
},
|
||||
);
|
||||
|
||||
expect(infoPlist.readAsStringSync().contains('NSBonjourServices'), isFalse);
|
||||
expect(infoPlist.readAsStringSync().contains('NSLocalNetworkUsageDescription'), isFalse);
|
||||
expect(result, const ProcessResultMatcher());
|
||||
});
|
||||
}, skip: !io.Platform.isMacOS); // [intended] requires macos toolchain.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user