Migrate xcodeproj to null safety (#80549)
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/commands/clean.dart';
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:flutter_tools/src/macos/xcode.dart';
|
||||
@@ -73,7 +74,7 @@ void main() {
|
||||
final FlutterProject projectUnderTest = setupProjectUnderTest(fs.currentDirectory);
|
||||
// Xcode is installed and version satisfactory.
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(1000);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(1000, 0, 0));
|
||||
await CleanCommand().runCommand();
|
||||
|
||||
expect(buildDirectory.existsSync(), isFalse);
|
||||
@@ -108,7 +109,7 @@ void main() {
|
||||
setupProjectUnderTest(fs.currentDirectory);
|
||||
// Xcode is installed and version satisfactory.
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(1000);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(1000, 0, 0));
|
||||
|
||||
await CleanCommand(verbose: true).runCommand();
|
||||
verify(mockXcodeProjectInterpreter.cleanWorkspace(any, 'Runner', verbose: true)).called(2);
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/device.dart';
|
||||
@@ -92,7 +93,7 @@ void main() {
|
||||
|
||||
mockXcodeProjectInterpreter = MockXcodeProjectInterpreter();
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(1000);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(1000, 0, 0));
|
||||
when(mockXcodeProjectInterpreter.xcrunCommand()).thenReturn(<String>['xcrun']);
|
||||
when(mockXcodeProjectInterpreter.getInfo(any, projectFilename: anyNamed('projectFilename'))).thenAnswer(
|
||||
(_) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/ios/ios_workflow.dart';
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:flutter_tools/src/macos/xcode.dart';
|
||||
@@ -60,9 +61,7 @@ void main() {
|
||||
processManager: FakeProcessManager.any(),
|
||||
xcodeProjectInterpreter: XcodeProjectInterpreter.test(
|
||||
processManager: FakeProcessManager.any(),
|
||||
majorVersion: 1000,
|
||||
minorVersion: 0,
|
||||
patchVersion: 0,
|
||||
version: Version(1000, 0, 0)
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/ios/xcodeproj.dart';
|
||||
import 'package:flutter_tools/src/ios/xcode_build_settings.dart';
|
||||
@@ -172,9 +173,7 @@ void main() {
|
||||
),
|
||||
]);
|
||||
|
||||
expect(xcodeProjectInterpreter.majorVersion, 11);
|
||||
expect(xcodeProjectInterpreter.minorVersion, 4);
|
||||
expect(xcodeProjectInterpreter.patchVersion, 1);
|
||||
expect(xcodeProjectInterpreter.version, Version(11, 4, 1));
|
||||
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
|
||||
});
|
||||
|
||||
@@ -188,9 +187,7 @@ void main() {
|
||||
),
|
||||
]);
|
||||
|
||||
expect(xcodeProjectInterpreter.majorVersion, 11);
|
||||
expect(xcodeProjectInterpreter.minorVersion, 0);
|
||||
expect(xcodeProjectInterpreter.patchVersion, 0);
|
||||
expect(xcodeProjectInterpreter.version, Version(11, 0, 0));
|
||||
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
|
||||
});
|
||||
|
||||
@@ -203,9 +200,7 @@ void main() {
|
||||
stdout: 'Xcode Ultra5000\nBuild version 8E3004b',
|
||||
),
|
||||
]);
|
||||
expect(xcodeProjectInterpreter.majorVersion, isNull);
|
||||
expect(xcodeProjectInterpreter.minorVersion, isNull);
|
||||
expect(xcodeProjectInterpreter.patchVersion, isNull);
|
||||
expect(xcodeProjectInterpreter.version, isNull);
|
||||
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
|
||||
});
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart' show ProcessException;
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/ios/devices.dart';
|
||||
@@ -137,9 +138,7 @@ void main() {
|
||||
|
||||
testWithoutContext('xcodeVersionSatisfactory is false when version is less than minimum', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(9);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(9, 0, 0));
|
||||
|
||||
expect(xcode.isRequiredVersionSatisfactory, isFalse);
|
||||
});
|
||||
@@ -152,45 +151,35 @@ void main() {
|
||||
|
||||
testWithoutContext('xcodeVersionSatisfactory is true when version meets minimum', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(12);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(1);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(12, 0, 1));
|
||||
|
||||
expect(xcode.isRequiredVersionSatisfactory, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('xcodeVersionSatisfactory is true when major version exceeds minimum', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(13);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(13, 0, 0));
|
||||
|
||||
expect(xcode.isRequiredVersionSatisfactory, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('xcodeVersionSatisfactory is true when minor version exceeds minimum', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(12);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(3);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(12, 3, 0));
|
||||
|
||||
expect(xcode.isRequiredVersionSatisfactory, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('xcodeVersionSatisfactory is true when patch version exceeds minimum', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(12);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(2);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(12, 0, 2));
|
||||
|
||||
expect(xcode.isRequiredVersionSatisfactory, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('isRecommendedVersionSatisfactory is false when version is less than minimum', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(11);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(11, 0, 0));
|
||||
|
||||
expect(xcode.isRecommendedVersionSatisfactory, isFalse);
|
||||
});
|
||||
@@ -203,36 +192,28 @@ void main() {
|
||||
|
||||
testWithoutContext('isRecommendedVersionSatisfactory is true when version meets minimum', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(12);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(1);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(12, 0, 1));
|
||||
|
||||
expect(xcode.isRecommendedVersionSatisfactory, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('isRecommendedVersionSatisfactory is true when major version exceeds minimum', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(13);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(13, 0, 0));
|
||||
|
||||
expect(xcode.isRecommendedVersionSatisfactory, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('isRecommendedVersionSatisfactory is true when minor version exceeds minimum', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(12);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(3);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(12, 3, 0));
|
||||
|
||||
expect(xcode.isRecommendedVersionSatisfactory, isTrue);
|
||||
});
|
||||
|
||||
testWithoutContext('isRecommendedVersionSatisfactory is true when patch version exceeds minimum', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(12);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(2);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(12, 0, 2));
|
||||
|
||||
expect(xcode.isRecommendedVersionSatisfactory, isTrue);
|
||||
});
|
||||
@@ -246,9 +227,7 @@ void main() {
|
||||
|
||||
testWithoutContext('isInstalledAndMeetsVersionCheck is false when version not satisfied', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(10);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(2);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(10, 2, 0));
|
||||
|
||||
expect(xcode.isInstalledAndMeetsVersionCheck, isFalse);
|
||||
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
|
||||
@@ -256,9 +235,7 @@ void main() {
|
||||
|
||||
testWithoutContext('isInstalledAndMeetsVersionCheck is true when macOS and installed and version is satisfied', () {
|
||||
when(mockXcodeProjectInterpreter.isInstalled).thenReturn(true);
|
||||
when(mockXcodeProjectInterpreter.majorVersion).thenReturn(12);
|
||||
when(mockXcodeProjectInterpreter.minorVersion).thenReturn(0);
|
||||
when(mockXcodeProjectInterpreter.patchVersion).thenReturn(1);
|
||||
when(mockXcodeProjectInterpreter.version).thenReturn(Version(12, 0, 1));
|
||||
|
||||
expect(xcode.isInstalledAndMeetsVersionCheck, isTrue);
|
||||
expect(fakeProcessManager.hasRemainingExpectations, isFalse);
|
||||
@@ -346,7 +323,7 @@ void main() {
|
||||
processManager: FakeProcessManager.any(),
|
||||
xcodeProjectInterpreter: XcodeProjectInterpreter.test(
|
||||
processManager: FakeProcessManager.any(),
|
||||
majorVersion: null, // Not installed.
|
||||
version: null, // Not installed.
|
||||
),
|
||||
);
|
||||
xcdevice = XCDevice(
|
||||
|
||||
@@ -26,6 +26,7 @@ baz=qux
|
||||
testWithoutContext('can parse and compare', () {
|
||||
expect(Version.unknown.toString(), equals('unknown'));
|
||||
expect(Version(null, null, null).toString(), equals('0'));
|
||||
expect(const Version.withText(1, 2, 3, 'versionText').toString(), 'versionText');
|
||||
|
||||
final Version v1 = Version.parse('1')!;
|
||||
expect(v1.major, equals(1));
|
||||
|
||||
@@ -18,6 +18,7 @@ import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/signals.dart';
|
||||
import 'package:flutter_tools/src/base/template.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/doctor_validator.dart';
|
||||
import 'package:flutter_tools/src/isolated/mustache_template.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
@@ -342,13 +343,7 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
|
||||
String get versionText => 'Xcode 12.0.1';
|
||||
|
||||
@override
|
||||
int get majorVersion => 12;
|
||||
|
||||
@override
|
||||
int get minorVersion => 0;
|
||||
|
||||
@override
|
||||
int get patchVersion => 1;
|
||||
Version get version => Version(12, 0, 1);
|
||||
|
||||
@override
|
||||
Future<Map<String, String>> getBuildSettings(
|
||||
|
||||
Reference in New Issue
Block a user