forked from firka/flutter
[flutter_tool] Remove the synchronous -showBuildSettings (#40435)
This commit is contained in:
@@ -325,7 +325,8 @@ void main() {
|
||||
testUsingContext('returns null when there is no ios or .ios directory', () async {
|
||||
fs.file('pubspec.yaml').createSync();
|
||||
fs.file('.packages').createSync();
|
||||
final BuildableIOSApp iosApp = IOSApp.fromIosProject(FlutterProject.fromDirectory(fs.currentDirectory).ios);
|
||||
final BuildableIOSApp iosApp = await IOSApp.fromIosProject(
|
||||
FlutterProject.fromDirectory(fs.currentDirectory).ios);
|
||||
|
||||
expect(iosApp, null);
|
||||
}, overrides: overrides);
|
||||
@@ -334,7 +335,8 @@ void main() {
|
||||
fs.file('pubspec.yaml').createSync();
|
||||
fs.file('.packages').createSync();
|
||||
fs.file('ios/FooBar.xcodeproj').createSync(recursive: true);
|
||||
final BuildableIOSApp iosApp = IOSApp.fromIosProject(FlutterProject.fromDirectory(fs.currentDirectory).ios);
|
||||
final BuildableIOSApp iosApp = await IOSApp.fromIosProject(
|
||||
FlutterProject.fromDirectory(fs.currentDirectory).ios);
|
||||
|
||||
expect(iosApp, null);
|
||||
}, overrides: overrides);
|
||||
@@ -343,7 +345,8 @@ void main() {
|
||||
fs.file('pubspec.yaml').createSync();
|
||||
fs.file('.packages').createSync();
|
||||
fs.file('ios/Runner.xcodeproj').createSync(recursive: true);
|
||||
final BuildableIOSApp iosApp = IOSApp.fromIosProject(FlutterProject.fromDirectory(fs.currentDirectory).ios);
|
||||
final BuildableIOSApp iosApp = await IOSApp.fromIosProject(
|
||||
FlutterProject.fromDirectory(fs.currentDirectory).ios);
|
||||
|
||||
expect(iosApp, null);
|
||||
}, overrides: overrides);
|
||||
|
||||
@@ -707,7 +707,7 @@ void main() {
|
||||
await runner.run(<String>['create', '--template=app', '--no-pub', '--org', 'com.example', tmpProjectDir]);
|
||||
FlutterProject project = FlutterProject.fromDirectory(fs.directory(tmpProjectDir));
|
||||
expect(
|
||||
project.ios.productBundleIdentifier,
|
||||
await project.ios.productBundleIdentifier,
|
||||
'com.example.helloFlutter',
|
||||
);
|
||||
expect(
|
||||
@@ -719,7 +719,7 @@ void main() {
|
||||
await runner.run(<String>['create', '--template=app', '--no-pub', '--org', 'abc^*.1#@', tmpProjectDir]);
|
||||
project = FlutterProject.fromDirectory(fs.directory(tmpProjectDir));
|
||||
expect(
|
||||
project.ios.productBundleIdentifier,
|
||||
await project.ios.productBundleIdentifier,
|
||||
'abc.1.testAbc',
|
||||
);
|
||||
expect(
|
||||
@@ -731,7 +731,7 @@ void main() {
|
||||
await runner.run(<String>['create', '--template=app', '--no-pub', '--org', '#+^%', tmpProjectDir]);
|
||||
project = FlutterProject.fromDirectory(fs.directory(tmpProjectDir));
|
||||
expect(
|
||||
project.ios.productBundleIdentifier,
|
||||
await project.ios.productBundleIdentifier,
|
||||
'flutterProject.untitled',
|
||||
);
|
||||
expect(
|
||||
@@ -856,7 +856,7 @@ void main() {
|
||||
await _createProject(projectDir, <String>[], <String>[]);
|
||||
final FlutterProject project = FlutterProject.fromDirectory(projectDir);
|
||||
expect(
|
||||
project.ios.productBundleIdentifier,
|
||||
await project.ios.productBundleIdentifier,
|
||||
'com.bar.foo.flutterProject',
|
||||
);
|
||||
}, timeout: allowForRemotePubInvocation);
|
||||
@@ -896,7 +896,7 @@ void main() {
|
||||
await _createProject(projectDir, <String>['--no-pub'], <String>[]);
|
||||
final FlutterProject project = FlutterProject.fromDirectory(projectDir);
|
||||
expect(
|
||||
project.ios.productBundleIdentifier,
|
||||
await project.ios.productBundleIdentifier,
|
||||
'com.bar.foo.flutterProject',
|
||||
);
|
||||
}, timeout: allowForCreateFlutterProject);
|
||||
@@ -929,7 +929,7 @@ void main() {
|
||||
);
|
||||
final FlutterProject project = FlutterProject.fromDirectory(projectDir);
|
||||
expect(
|
||||
project.example.ios.productBundleIdentifier,
|
||||
await project.example.ios.productBundleIdentifier,
|
||||
'com.bar.foo.flutterProjectExample',
|
||||
);
|
||||
}, timeout: allowForCreateFlutterProject);
|
||||
|
||||
@@ -27,16 +27,18 @@ void main() {
|
||||
BuildableIOSApp app;
|
||||
AnsiTerminal testTerminal;
|
||||
|
||||
setUp(() {
|
||||
setUp(() async {
|
||||
mockProcessManager = MockProcessManager();
|
||||
mockConfig = MockConfig();
|
||||
mockIosProject = MockIosProject();
|
||||
when(mockIosProject.buildSettings).thenReturn(<String, String>{
|
||||
'For our purposes': 'a non-empty build settings map is valid',
|
||||
when(mockIosProject.buildSettings).thenAnswer((_) {
|
||||
return Future<Map<String, String>>.value(<String, String>{
|
||||
'For our purposes': 'a non-empty build settings map is valid',
|
||||
});
|
||||
});
|
||||
testTerminal = TestTerminal();
|
||||
testTerminal.usesTerminalUi = true;
|
||||
app = BuildableIOSApp(mockIosProject);
|
||||
app = await BuildableIOSApp.fromProject(mockIosProject);
|
||||
});
|
||||
|
||||
testUsingContext('No auto-sign if Xcode project settings are not available', () async {
|
||||
@@ -46,8 +48,10 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('No discovery if development team specified in Xcode project', () async {
|
||||
when(mockIosProject.buildSettings).thenReturn(<String, String>{
|
||||
'DEVELOPMENT_TEAM': 'abc',
|
||||
when(mockIosProject.buildSettings).thenAnswer((_) {
|
||||
return Future<Map<String, String>>.value(<String, String>{
|
||||
'DEVELOPMENT_TEAM': 'abc',
|
||||
});
|
||||
});
|
||||
final Map<String, String> signingConfigs = await getCodeSigningIdentityDevelopmentTeam(iosApp: app);
|
||||
expect(signingConfigs, isNull);
|
||||
|
||||
@@ -295,8 +295,8 @@ void main() {
|
||||
projectDir.path,
|
||||
]);
|
||||
|
||||
final IOSApp app =
|
||||
AbsoluteBuildableIOSApp(FlutterProject.fromDirectory(projectDir).ios);
|
||||
final IOSApp app = await AbsoluteBuildableIOSApp.fromProject(
|
||||
FlutterProject.fromDirectory(projectDir).ios);
|
||||
final IOSDevice device = IOSDevice('123');
|
||||
|
||||
// Pre-create the expected build products.
|
||||
@@ -547,7 +547,7 @@ Runner(UIKit)[297] <Notice>: E is for enpitsu"
|
||||
|
||||
final IOSDevice device = IOSDevice('123456');
|
||||
final DeviceLogReader logReader = device.getLogReader(
|
||||
app: BuildableIOSApp(mockIosProject),
|
||||
app: await BuildableIOSApp.fromProject(mockIosProject),
|
||||
);
|
||||
|
||||
final List<String> lines = await logReader.logLines.toList();
|
||||
@@ -572,7 +572,7 @@ Runner(libsystem_asl.dylib)[297] <Notice>: libMobileGestalt
|
||||
|
||||
final IOSDevice device = IOSDevice('123456');
|
||||
final DeviceLogReader logReader = device.getLogReader(
|
||||
app: BuildableIOSApp(mockIosProject),
|
||||
app: await BuildableIOSApp.fromProject(mockIosProject),
|
||||
);
|
||||
|
||||
final List<String> lines = await logReader.logLines.toList();
|
||||
@@ -630,7 +630,13 @@ flutter:
|
||||
}
|
||||
|
||||
class AbsoluteBuildableIOSApp extends BuildableIOSApp {
|
||||
AbsoluteBuildableIOSApp(IosProject project) : super(project);
|
||||
AbsoluteBuildableIOSApp(IosProject project, String projectBundleId) :
|
||||
super(project, projectBundleId);
|
||||
|
||||
static Future<AbsoluteBuildableIOSApp> fromProject(IosProject project) async {
|
||||
final String projectBundleId = await project.productBundleIdentifier;
|
||||
return AbsoluteBuildableIOSApp(project, projectBundleId);
|
||||
}
|
||||
|
||||
@override
|
||||
String get deviceBundlePath =>
|
||||
|
||||
@@ -338,7 +338,7 @@ void main() {
|
||||
|
||||
final IOSSimulator device = IOSSimulator('123456', simulatorCategory: 'iOS 11.0');
|
||||
final DeviceLogReader logReader = device.getLogReader(
|
||||
app: BuildableIOSApp(mockIosProject),
|
||||
app: await BuildableIOSApp.fromProject(mockIosProject),
|
||||
);
|
||||
|
||||
final List<String> lines = await logReader.logLines.toList();
|
||||
|
||||
@@ -145,13 +145,13 @@ void main() {
|
||||
expect(xcodeProjectInterpreter.isInstalled, isTrue);
|
||||
});
|
||||
|
||||
testUsingOsxContext('build settings is empty when xcodebuild failed to get the build settings', () {
|
||||
testUsingOsxContext('build settings is empty when xcodebuild failed to get the build settings', () async {
|
||||
when(mockProcessManager.runSync(
|
||||
argThat(contains(xcodebuild)),
|
||||
workingDirectory: anyNamed('workingDirectory'),
|
||||
environment: anyNamed('environment')))
|
||||
.thenReturn(ProcessResult(0, 1, '', ''));
|
||||
expect(xcodeProjectInterpreter.getBuildSettings('', ''), const <String, String>{});
|
||||
expect(await xcodeProjectInterpreter.getBuildSettings('', ''), const <String, String>{});
|
||||
});
|
||||
|
||||
testUsingContext('build settings flakes', () async {
|
||||
@@ -160,7 +160,7 @@ void main() {
|
||||
flakes: 1,
|
||||
delay: delay + const Duration(seconds: 1),
|
||||
);
|
||||
expect(await xcodeProjectInterpreter.getBuildSettingsAsync(
|
||||
expect(await xcodeProjectInterpreter.getBuildSettings(
|
||||
'', '', timeout: delay),
|
||||
const <String, String>{});
|
||||
// build settings times out and is killed once, then succeeds.
|
||||
|
||||
@@ -173,7 +173,7 @@ void main() {
|
||||
|
||||
testUsingContext('creates swift Podfile if swift', () async {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.getBuildSettingsAsync(any, any))
|
||||
when(mockXcodeProjectInterpreter.getBuildSettings(any, any))
|
||||
.thenAnswer((_) async => <String, String>{
|
||||
'SWIFT_VERSION': '4.0',
|
||||
});
|
||||
|
||||
@@ -257,15 +257,18 @@ void main() {
|
||||
|
||||
testInMemory('default host app language', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
expect(project.ios.isSwift, isFalse);
|
||||
expect(await project.ios.isSwift, isFalse);
|
||||
expect(project.android.isKotlin, isFalse);
|
||||
});
|
||||
|
||||
testUsingContext('swift and kotlin host app language', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
|
||||
when(mockXcodeProjectInterpreter.getBuildSettings(any, any)).thenReturn(<String, String>{
|
||||
'SWIFT_VERSION': '4.0',
|
||||
when(mockXcodeProjectInterpreter.getBuildSettings(any, any)).thenAnswer(
|
||||
(_) {
|
||||
return Future<Map<String, String>>.value(<String, String>{
|
||||
'SWIFT_VERSION': '4.0',
|
||||
});
|
||||
});
|
||||
addAndroidGradleFile(project.directory,
|
||||
gradleFileContent: () {
|
||||
@@ -274,7 +277,7 @@ apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
''';
|
||||
});
|
||||
expect(project.ios.isSwift, isTrue);
|
||||
expect(await project.ios.isSwift, isTrue);
|
||||
expect(project.android.isKotlin, isTrue);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fs,
|
||||
@@ -306,19 +309,19 @@ apply plugin: 'kotlin-android'
|
||||
|
||||
testWithMocks('null, if no pbxproj or plist entries', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
expect(project.ios.productBundleIdentifier, isNull);
|
||||
expect(await project.ios.productBundleIdentifier, isNull);
|
||||
});
|
||||
testWithMocks('from pbxproj file, if no plist', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
addIosProjectFile(project.directory, projectFileContent: () {
|
||||
return projectFileWithBundleId('io.flutter.someProject');
|
||||
});
|
||||
expect(project.ios.productBundleIdentifier, 'io.flutter.someProject');
|
||||
expect(await project.ios.productBundleIdentifier, 'io.flutter.someProject');
|
||||
});
|
||||
testWithMocks('from plist, if no variables', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
when(mockPlistUtils.getValueFromFile(any, any)).thenReturn('io.flutter.someProject');
|
||||
expect(project.ios.productBundleIdentifier, 'io.flutter.someProject');
|
||||
expect(await project.ios.productBundleIdentifier, 'io.flutter.someProject');
|
||||
});
|
||||
testWithMocks('from pbxproj and plist, if default variable', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
@@ -326,56 +329,60 @@ apply plugin: 'kotlin-android'
|
||||
return projectFileWithBundleId('io.flutter.someProject');
|
||||
});
|
||||
when(mockPlistUtils.getValueFromFile(any, any)).thenReturn('\$(PRODUCT_BUNDLE_IDENTIFIER)');
|
||||
expect(project.ios.productBundleIdentifier, 'io.flutter.someProject');
|
||||
expect(await project.ios.productBundleIdentifier, 'io.flutter.someProject');
|
||||
});
|
||||
testWithMocks('from pbxproj and plist, by substitution', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
when(mockXcodeProjectInterpreter.getBuildSettings(any, any)).thenReturn(<String, String>{
|
||||
'PRODUCT_BUNDLE_IDENTIFIER': 'io.flutter.someProject',
|
||||
'SUFFIX': 'suffix',
|
||||
});
|
||||
when(mockXcodeProjectInterpreter.getBuildSettings(any, any)).thenAnswer(
|
||||
(_) {
|
||||
return Future<Map<String,String>>.value(<String, String>{
|
||||
'PRODUCT_BUNDLE_IDENTIFIER': 'io.flutter.someProject',
|
||||
'SUFFIX': 'suffix',
|
||||
});
|
||||
}
|
||||
);
|
||||
when(mockPlistUtils.getValueFromFile(any, any)).thenReturn('\$(PRODUCT_BUNDLE_IDENTIFIER).\$(SUFFIX)');
|
||||
expect(project.ios.productBundleIdentifier, 'io.flutter.someProject.suffix');
|
||||
expect(await project.ios.productBundleIdentifier, 'io.flutter.someProject.suffix');
|
||||
});
|
||||
testWithMocks('empty surrounded by quotes', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
addIosProjectFile(project.directory, projectFileContent: () {
|
||||
return projectFileWithBundleId('', qualifier: '"');
|
||||
});
|
||||
expect(project.ios.productBundleIdentifier, '');
|
||||
expect(await project.ios.productBundleIdentifier, '');
|
||||
});
|
||||
testWithMocks('surrounded by double quotes', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
addIosProjectFile(project.directory, projectFileContent: () {
|
||||
return projectFileWithBundleId('io.flutter.someProject', qualifier: '"');
|
||||
});
|
||||
expect(project.ios.productBundleIdentifier, 'io.flutter.someProject');
|
||||
expect(await project.ios.productBundleIdentifier, 'io.flutter.someProject');
|
||||
});
|
||||
testWithMocks('surrounded by single quotes', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
addIosProjectFile(project.directory, projectFileContent: () {
|
||||
return projectFileWithBundleId('io.flutter.someProject', qualifier: '\'');
|
||||
});
|
||||
expect(project.ios.productBundleIdentifier, 'io.flutter.someProject');
|
||||
expect(await project.ios.productBundleIdentifier, 'io.flutter.someProject');
|
||||
});
|
||||
});
|
||||
|
||||
group('organization names set', () {
|
||||
testInMemory('is empty, if project not created', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
expect(project.organizationNames, isEmpty);
|
||||
expect(await project.organizationNames, isEmpty);
|
||||
});
|
||||
testInMemory('is empty, if no platform folders exist', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
project.directory.createSync();
|
||||
expect(project.organizationNames, isEmpty);
|
||||
expect(await project.organizationNames, isEmpty);
|
||||
});
|
||||
testInMemory('is populated from iOS bundle identifier', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
addIosProjectFile(project.directory, projectFileContent: () {
|
||||
return projectFileWithBundleId('io.flutter.someProject', qualifier: '\'');
|
||||
});
|
||||
expect(project.organizationNames, <String>['io.flutter']);
|
||||
expect(await project.organizationNames, <String>['io.flutter']);
|
||||
});
|
||||
testInMemory('is populated from Android application ID', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
@@ -383,14 +390,14 @@ apply plugin: 'kotlin-android'
|
||||
gradleFileContent: () {
|
||||
return gradleFileWithApplicationId('io.flutter.someproject');
|
||||
});
|
||||
expect(project.organizationNames, <String>['io.flutter']);
|
||||
expect(await project.organizationNames, <String>['io.flutter']);
|
||||
});
|
||||
testInMemory('is populated from iOS bundle identifier in plugin example', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
addIosProjectFile(project.example.directory, projectFileContent: () {
|
||||
return projectFileWithBundleId('io.flutter.someProject', qualifier: '\'');
|
||||
});
|
||||
expect(project.organizationNames, <String>['io.flutter']);
|
||||
expect(await project.organizationNames, <String>['io.flutter']);
|
||||
});
|
||||
testInMemory('is populated from Android application ID in plugin example', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
@@ -398,12 +405,12 @@ apply plugin: 'kotlin-android'
|
||||
gradleFileContent: () {
|
||||
return gradleFileWithApplicationId('io.flutter.someproject');
|
||||
});
|
||||
expect(project.organizationNames, <String>['io.flutter']);
|
||||
expect(await project.organizationNames, <String>['io.flutter']);
|
||||
});
|
||||
testInMemory('is populated from Android group in plugin', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
addAndroidWithGroup(project.directory, 'io.flutter.someproject');
|
||||
expect(project.organizationNames, <String>['io.flutter']);
|
||||
expect(await project.organizationNames, <String>['io.flutter']);
|
||||
});
|
||||
testInMemory('is singleton, if sources agree', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
@@ -414,7 +421,7 @@ apply plugin: 'kotlin-android'
|
||||
gradleFileContent: () {
|
||||
return gradleFileWithApplicationId('io.flutter.someproject');
|
||||
});
|
||||
expect(project.organizationNames, <String>['io.flutter']);
|
||||
expect(await project.organizationNames, <String>['io.flutter']);
|
||||
});
|
||||
testInMemory('is non-singleton, if sources disagree', () async {
|
||||
final FlutterProject project = await someProject();
|
||||
@@ -426,7 +433,7 @@ apply plugin: 'kotlin-android'
|
||||
return gradleFileWithApplicationId('io.clutter.someproject');
|
||||
});
|
||||
expect(
|
||||
project.organizationNames,
|
||||
await project.organizationNames,
|
||||
<String>['io.flutter', 'io.clutter'],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -333,12 +333,7 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
|
||||
int get minorVersion => 2;
|
||||
|
||||
@override
|
||||
Map<String, String> getBuildSettings(String projectPath, String target) {
|
||||
return <String, String>{};
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, String>> getBuildSettingsAsync(
|
||||
Future<Map<String, String>> getBuildSettings(
|
||||
String projectPath,
|
||||
String target, {
|
||||
Duration timeout = const Duration(minutes: 1),
|
||||
|
||||
@@ -26,7 +26,11 @@ import 'package:process/process.dart';
|
||||
|
||||
import 'common.dart';
|
||||
|
||||
final Generator kNoColorTerminalPlatform = () => FakePlatform.fromPlatform(const LocalPlatform())..stdoutSupportsAnsi = false;
|
||||
final Generator kNoColorTerminalPlatform = () {
|
||||
return FakePlatform.fromPlatform(
|
||||
const LocalPlatform()
|
||||
)..stdoutSupportsAnsi = false;
|
||||
};
|
||||
|
||||
class MockApplicationPackageStore extends ApplicationPackageStore {
|
||||
MockApplicationPackageStore() : super(
|
||||
@@ -36,7 +40,7 @@ class MockApplicationPackageStore extends ApplicationPackageStore {
|
||||
versionCode: 1,
|
||||
launchActivity: 'io.flutter.android.mock.MockActivity',
|
||||
),
|
||||
iOS: BuildableIOSApp(MockIosProject())
|
||||
iOS: BuildableIOSApp(MockIosProject(), MockIosProject.bundleId)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -513,8 +517,10 @@ class MockPollingDeviceDiscovery extends PollingDeviceDiscovery {
|
||||
}
|
||||
|
||||
class MockIosProject extends Mock implements IosProject {
|
||||
static const String bundleId = 'com.example.test';
|
||||
|
||||
@override
|
||||
String get productBundleIdentifier => 'com.example.test';
|
||||
Future<String> get productBundleIdentifier async => bundleId;
|
||||
|
||||
@override
|
||||
String get hostAppBundleName => 'Runner.app';
|
||||
|
||||
Reference in New Issue
Block a user