Return void from project migrate() (#112897)

This commit is contained in:
Jenn Magder
2022-10-05 13:22:56 -07:00
committed by GitHub
parent 69fc4fb622
commit b82cf76ff6
21 changed files with 73 additions and 134 deletions

View File

@@ -30,15 +30,9 @@ void main () {
});
testWithoutContext('migrators succeed', () {
final FakeIOSMigrator fakeIOSMigrator = FakeIOSMigrator(succeeds: true);
final FakeIOSMigrator fakeIOSMigrator = FakeIOSMigrator();
final ProjectMigration migration = ProjectMigration(<ProjectMigrator>[fakeIOSMigrator]);
expect(migration.run(), isTrue);
});
testWithoutContext('migrators fail', () {
final FakeIOSMigrator fakeIOSMigrator = FakeIOSMigrator(succeeds: false);
final ProjectMigration migration = ProjectMigration(<ProjectMigrator>[fakeIOSMigrator]);
expect(migration.run(), isFalse);
migration.run();
});
group('remove framework linking and embedding migration', () {
@@ -61,7 +55,7 @@ void main () {
testLogger,
testUsage
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(testUsage.events, isEmpty);
expect(xcodeProjectInfoFile.existsSync(), isFalse);
@@ -80,7 +74,7 @@ void main () {
testLogger,
testUsage,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(testUsage.events, isEmpty);
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
@@ -100,7 +94,7 @@ shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.
testLogger,
testUsage,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.readAsStringSync(), contents);
expect(testLogger.statusText, isEmpty);
});
@@ -127,7 +121,7 @@ keep this 2
testLogger,
testUsage,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(testUsage.events, isEmpty);
expect(xcodeProjectInfoFile.readAsStringSync(), r'''
@@ -207,7 +201,7 @@ keep this 2
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeWorkspaceSharedSettings.existsSync(), isFalse);
expect(testLogger.traceText, contains('Xcode workspace settings not found, skipping build system migration'));
@@ -230,7 +224,7 @@ keep this 2
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeWorkspaceSharedSettings.existsSync(), isTrue);
expect(testLogger.statusText, isEmpty);
});
@@ -253,7 +247,7 @@ keep this 2
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeWorkspaceSharedSettings.existsSync(), isFalse);
expect(testLogger.statusText, contains('Legacy build system detected, removing'));
@@ -279,7 +273,7 @@ keep this 2
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectWorkspaceData.existsSync(), isFalse);
expect(testLogger.traceText, contains('Xcode project workspace data not found, skipping build location migration.'));
@@ -301,7 +295,7 @@ keep this 2
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectWorkspaceData.existsSync(), isTrue);
expect(testLogger.statusText, isEmpty);
});
@@ -325,7 +319,7 @@ keep this 2
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectWorkspaceData.readAsStringSync(), '''
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
@@ -358,7 +352,7 @@ keep this 2
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.existsSync(), isFalse);
expect(testLogger.traceText, contains('Xcode project not found, skipping Runner project build settings and configuration migration'));
@@ -374,7 +368,7 @@ keep this 2
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
expect(xcodeProjectInfoFile.readAsStringSync(), contents);
@@ -402,7 +396,7 @@ keep this 3
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.readAsStringSync(), '''
97C147031CF9000F007C117D /* Debug */ = {
@@ -457,7 +451,7 @@ keep this 3
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.readAsStringSync(), '''
97C147031CF9000F007C1171 /* Debug */ = {
@@ -520,7 +514,7 @@ keep this 3
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.existsSync(), isFalse);
expect(appFrameworkInfoPlist.existsSync(), isFalse);
expect(podfile.existsSync(), isFalse);
@@ -551,7 +545,7 @@ keep this 3
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
expect(xcodeProjectInfoFile.readAsStringSync(), xcodeProjectInfoFileContents);
@@ -597,7 +591,7 @@ platform :ios, '9.0'
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.readAsStringSync(), '''
GCC_WARN_UNUSED_VARIABLE = YES;
@@ -656,7 +650,7 @@ platform :ios, '11.0'
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.existsSync(), isFalse);
expect(xcodeProjectSchemeFile.existsSync(), isFalse);
@@ -688,7 +682,7 @@ platform :ios, '11.0'
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
expect(xcodeProjectInfoFile.readAsStringSync(), xcodeProjectInfoFileContents);
@@ -718,7 +712,7 @@ platform :ios, '11.0'
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.readAsStringSync(), '''
classes = {
@@ -759,7 +753,7 @@ platform :ios, '11.0'
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(infoPlistFile.existsSync(), isFalse);
expect(testLogger.traceText, contains('Info.plist not found, skipping host app Info.plist migration.'));
@@ -786,7 +780,7 @@ platform :ios, '11.0'
testLogger,
);
final DateTime infoPlistFileLastModified = infoPlistFile.lastModifiedSync();
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(infoPlistFile.lastModifiedSync(), infoPlistFileLastModified);
expect(testLogger.statusText, isEmpty);
@@ -807,7 +801,7 @@ platform :ios, '11.0'
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(infoPlistFile.readAsStringSync(), equals('''
<?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">
@@ -913,7 +907,7 @@ platform :ios, '11.0'
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.existsSync(), isFalse);
expect(testLogger.traceText, contains('Xcode project not found, skipping script build phase dependency analysis removal'));
@@ -939,7 +933,7 @@ platform :ios, '11.0'
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
expect(xcodeProjectInfoFile.readAsStringSync(), xcodeProjectInfoFileContents);
@@ -970,7 +964,7 @@ platform :ios, '11.0'
project,
testLogger,
);
expect(iosProjectMigration.migrate(), isTrue);
iosProjectMigration.migrate();
expect(xcodeProjectInfoFile.readAsStringSync(), '''
/* Begin PBXShellScriptBuildPhase section */
@@ -1020,15 +1014,11 @@ class FakeIosProject extends Fake implements IosProject {
}
class FakeIOSMigrator extends ProjectMigrator {
FakeIOSMigrator({required this.succeeds})
FakeIOSMigrator()
: super(BufferLogger.test());
final bool succeeds;
@override
bool migrate() {
return succeeds;
}
void migrate() {}
@override
String migrateLine(String line) {

View File

@@ -37,7 +37,7 @@ void main() {
testLogger,
testUsage,
);
expect(macosProjectMigration.migrate(), isTrue);
macosProjectMigration.migrate();
expect(testUsage.events, isEmpty);
expect(xcodeProjectInfoFile.existsSync(), isFalse);
@@ -61,7 +61,7 @@ void main() {
testLogger,
testUsage,
);
expect(macosProjectMigration.migrate(), isTrue);
macosProjectMigration.migrate();
expect(testUsage.events, isEmpty);
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
@@ -82,7 +82,7 @@ shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.
testLogger,
testUsage,
);
expect(macosProjectMigration.migrate(), isTrue);
macosProjectMigration.migrate();
expect(xcodeProjectInfoFile.readAsStringSync(), contents);
expect(testLogger.statusText, isEmpty);
});
@@ -105,7 +105,7 @@ keep this 2
testLogger,
testUsage,
);
expect(macosProjectMigration.migrate(), isTrue);
macosProjectMigration.migrate();
expect(testUsage.events, isEmpty);
expect(xcodeProjectInfoFile.readAsStringSync(), r'''
@@ -178,7 +178,7 @@ keep this 2
project,
testLogger,
);
expect(macOSProjectMigration.migrate(), isTrue);
macOSProjectMigration.migrate();
expect(xcodeProjectInfoFile.existsSync(), isFalse);
expect(podfile.existsSync(), isFalse);
@@ -201,7 +201,7 @@ keep this 2
project,
testLogger,
);
expect(macOSProjectMigration.migrate(), isTrue);
macOSProjectMigration.migrate();
expect(xcodeProjectInfoFile.lastModifiedSync(), projectLastModified);
expect(xcodeProjectInfoFile.readAsStringSync(), xcodeProjectInfoFileContents);
@@ -227,7 +227,7 @@ platform :osx, '10.11'
project,
testLogger,
);
expect(macOSProjectMigration.migrate(), isTrue);
macOSProjectMigration.migrate();
expect(xcodeProjectInfoFile.readAsStringSync(), '''
GCC_WARN_UNUSED_VARIABLE = YES;

View File

@@ -15,18 +15,6 @@ import '../../src/common.dart';
void main () {
group('CMake project migration', () {
testWithoutContext('migrators succeed', () {
final FakeCmakeMigrator fakeCmakeMigrator = FakeCmakeMigrator(succeeds: true);
final ProjectMigration migration = ProjectMigration(<ProjectMigrator>[fakeCmakeMigrator]);
expect(migration.run(), isTrue);
});
testWithoutContext('migrators fail', () {
final FakeCmakeMigrator fakeCmakeMigrator = FakeCmakeMigrator(succeeds: false);
final ProjectMigration migration = ProjectMigration(<ProjectMigrator>[fakeCmakeMigrator]);
expect(migration.run(), isFalse);
});
group('migrate add_custom_command() to use VERBATIM', () {
late MemoryFileSystem memoryFileSystem;
late BufferLogger testLogger;
@@ -50,7 +38,7 @@ void main () {
mockCmakeProject,
testLogger,
);
expect(cmakeProjectMigration.migrate(), isTrue);
cmakeProjectMigration.migrate();
expect(managedCmakeFile.existsSync(), isFalse);
expect(testLogger.traceText, contains('CMake project not found, skipping add_custom_command() VERBATIM migration'));
@@ -66,7 +54,7 @@ void main () {
mockCmakeProject,
testLogger,
);
expect(cmakeProjectMigration.migrate(), isTrue);
cmakeProjectMigration.migrate();
expect(managedCmakeFile.lastModifiedSync(), projectLastModified);
expect(managedCmakeFile.readAsStringSync(), contents);
@@ -93,7 +81,7 @@ add_custom_command(
mockCmakeProject,
testLogger,
);
expect(cmakeProjectMigration.migrate(), isTrue);
cmakeProjectMigration.migrate();
expect(managedCmakeFile.lastModifiedSync(), projectLastModified);
expect(managedCmakeFile.readAsStringSync(), contents);
@@ -117,7 +105,7 @@ add_custom_command(
mockCmakeProject,
testLogger,
);
expect(cmakeProjectMigration.migrate(), isTrue);
cmakeProjectMigration.migrate();
expect(managedCmakeFile.readAsStringSync(), r'''
add_custom_command(
@@ -151,7 +139,7 @@ add_custom_command(
mockCmakeProject,
testLogger,
);
expect(cmakeProjectMigration.migrate(), isTrue);
cmakeProjectMigration.migrate();
expect(managedCmakeFile.readAsStringSync(), r'''
add_custom_command(
@@ -179,15 +167,11 @@ class FakeCmakeProject extends Fake implements CmakeBasedProject {
}
class FakeCmakeMigrator extends ProjectMigrator {
FakeCmakeMigrator({required this.succeeds})
FakeCmakeMigrator()
: super(BufferLogger.test());
final bool succeeds;
@override
bool migrate() {
return succeeds;
}
void migrate() { }
@override
String migrateLine(String line) {