-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shorebird_cli): support asset diffing in iOS frameworks (#1046)
- Loading branch information
1 parent
1ec6af9
commit 4e9b202
Showing
14 changed files
with
347 additions
and
133 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/shorebird_cli/lib/src/archive_analysis/archive_analysis.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export 'android_archive_differ.dart'; | ||
export 'file_set_diff.dart'; | ||
export 'ios_archive_differ.dart'; | ||
export 'ipa.dart'; | ||
export 'ipa_differ.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
The xcframework files in this folder were generated by building the stock Flutter counter app with `shorebird release ios-framework-alpha` and zipped with the `ditto` command. | ||
|
||
Files: | ||
|
||
- base.xcframework.zip is meant to represent an xcframework uploaded as part of a release. | ||
- changed_asset.xcframework.zip is meant to represent an xcframework generated with a changed asset file. | ||
- changed_dart.xcframework.zip is meant to represent an xcframework generated with a changed dart file. |
Binary file added
BIN
+2.21 MB
packages/shorebird_cli/test/fixtures/xcframeworks/base.xcframework.zip
Binary file not shown.
Binary file added
BIN
+2.21 MB
packages/shorebird_cli/test/fixtures/xcframeworks/changed_asset.xcframework.zip
Binary file not shown.
Binary file added
BIN
+2.21 MB
packages/shorebird_cli/test/fixtures/xcframeworks/changed_dart.xcframework.zip
Binary file not shown.
168 changes: 168 additions & 0 deletions
168
packages/shorebird_cli/test/src/archive_analysis/ios_archive_differ_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
import 'package:path/path.dart' as p; | ||
import 'package:shorebird_cli/src/archive_analysis/archive_analysis.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
final ipaFixturesBasePath = p.join('test', 'fixtures', 'ipas'); | ||
final baseIpaPath = p.join(ipaFixturesBasePath, 'base.ipa'); | ||
final changedAssetIpaPath = p.join(ipaFixturesBasePath, 'asset_changes.ipa'); | ||
final changedDartIpaPath = p.join(ipaFixturesBasePath, 'dart_changes.ipa'); | ||
final changedSwiftIpaPath = p.join(ipaFixturesBasePath, 'swift_changes.ipa'); | ||
|
||
final xcframeworkFixturesBasePath = p.join( | ||
'test', | ||
'fixtures', | ||
'xcframeworks', | ||
); | ||
final baseXcframeworkPath = | ||
p.join(xcframeworkFixturesBasePath, 'base.xcframework.zip'); | ||
final changedAssetXcframeworkPath = | ||
p.join(xcframeworkFixturesBasePath, 'changed_asset.xcframework.zip'); | ||
final changedDartXcframeworkPath = | ||
p.join(xcframeworkFixturesBasePath, 'changed_dart.xcframework.zip'); | ||
|
||
group(IosArchiveDiffer, () { | ||
late IosArchiveDiffer differ; | ||
|
||
setUp(() { | ||
differ = IosArchiveDiffer(); | ||
}); | ||
|
||
group('ipa', () { | ||
group('changedPaths', () { | ||
test('finds no differences between the same ipa', () { | ||
expect(differ.changedFiles(baseIpaPath, baseIpaPath), isEmpty); | ||
}); | ||
|
||
test('finds differences between two different ipas', () { | ||
expect( | ||
differ.changedFiles(baseIpaPath, changedAssetIpaPath).changedPaths, | ||
{ | ||
'Payload/Runner.app/_CodeSignature/CodeResources', | ||
'Payload/Runner.app/Runner', | ||
'Payload/Runner.app/Frameworks/Flutter.framework/Flutter', | ||
'Payload/Runner.app/Frameworks/App.framework/_CodeSignature/CodeResources', | ||
'Payload/Runner.app/Frameworks/App.framework/App', | ||
'Payload/Runner.app/Frameworks/App.framework/flutter_assets/assets/asset.json', | ||
'Symbols/4C4C4411-5555-3144-A13A-E47369D8ACD5.symbols', | ||
'Symbols/BC970605-0A53-3457-8736-D7A870AB6E71.symbols', | ||
'Symbols/0CBBC9EF-0745-3074-81B7-765F5B4515FD.symbols', | ||
}, | ||
); | ||
}); | ||
}); | ||
|
||
group('changedFiles', () { | ||
test('detects asset changes', () { | ||
final fileSetDiff = | ||
differ.changedFiles(baseIpaPath, changedAssetIpaPath); | ||
expect(differ.assetsFileSetDiff(fileSetDiff), isNotEmpty); | ||
expect(differ.dartFileSetDiff(fileSetDiff), isNotEmpty); | ||
expect(differ.nativeFileSetDiff(fileSetDiff), isNotEmpty); | ||
}); | ||
|
||
test('detects dart changes', () { | ||
final fileSetDiff = | ||
differ.changedFiles(baseIpaPath, changedDartIpaPath); | ||
expect(differ.assetsFileSetDiff(fileSetDiff), isEmpty); | ||
expect(differ.dartFileSetDiff(fileSetDiff), isNotEmpty); | ||
expect(differ.nativeFileSetDiff(fileSetDiff), isNotEmpty); | ||
}); | ||
|
||
test('detects swift changes', () { | ||
final fileSetDiff = | ||
differ.changedFiles(baseIpaPath, changedSwiftIpaPath); | ||
expect(differ.assetsFileSetDiff(fileSetDiff), isEmpty); | ||
expect(differ.dartFileSetDiff(fileSetDiff), isNotEmpty); | ||
expect(differ.nativeFileSetDiff(fileSetDiff), isNotEmpty); | ||
}); | ||
}); | ||
|
||
group('containsPotentiallyBreakingAssetDiffs', () { | ||
test('returns true if a file in flutter_assets has changed', () { | ||
final fileSetDiff = differ.changedFiles( | ||
baseIpaPath, | ||
changedAssetIpaPath, | ||
); | ||
expect( | ||
differ.containsPotentiallyBreakingAssetDiffs(fileSetDiff), | ||
isTrue, | ||
); | ||
}); | ||
|
||
test('returns false if no files in flutter_assets has changed', () { | ||
final fileSetDiff = differ.changedFiles( | ||
baseIpaPath, | ||
changedDartIpaPath, | ||
); | ||
expect( | ||
differ.containsPotentiallyBreakingAssetDiffs(fileSetDiff), | ||
isFalse, | ||
); | ||
}); | ||
}); | ||
|
||
group('containsPotentiallyBreakingNativeDiffs', () { | ||
test("always returns false, as we don't check for this yet", () { | ||
final fileSetDiff = differ.changedFiles( | ||
baseIpaPath, | ||
changedSwiftIpaPath, | ||
); | ||
expect( | ||
differ.containsPotentiallyBreakingNativeDiffs(fileSetDiff), | ||
isFalse, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
group('xcframework', () { | ||
group('changedPaths', () { | ||
test('finds no differences between the same zipped xcframeworks', () { | ||
expect( | ||
differ.changedFiles(baseXcframeworkPath, baseXcframeworkPath), | ||
isEmpty, | ||
); | ||
}); | ||
|
||
test('finds differences between two differed zipped xcframeworks', () { | ||
expect( | ||
differ | ||
.changedFiles(baseXcframeworkPath, changedAssetXcframeworkPath) | ||
.changedPaths, | ||
{ | ||
'ios-arm64_x86_64-simulator/App.framework/_CodeSignature/CodeResources', | ||
'ios-arm64_x86_64-simulator/App.framework/App', | ||
'ios-arm64_x86_64-simulator/App.framework/flutter_assets/assets/asset.json', | ||
'ios-arm64/App.framework/_CodeSignature/CodeResources', | ||
'ios-arm64/App.framework/App', | ||
'ios-arm64/App.framework/flutter_assets/assets/asset.json' | ||
}, | ||
); | ||
}); | ||
}); | ||
|
||
group('changedFiles', () { | ||
test('detects asset changes', () { | ||
final fileSetDiff = differ.changedFiles( | ||
baseXcframeworkPath, | ||
changedAssetXcframeworkPath, | ||
); | ||
expect(differ.assetsFileSetDiff(fileSetDiff), isNotEmpty); | ||
expect(differ.dartFileSetDiff(fileSetDiff), isNotEmpty); | ||
expect(differ.nativeFileSetDiff(fileSetDiff), isEmpty); | ||
}); | ||
|
||
test('detects dart changes', () { | ||
final fileSetDiff = differ.changedFiles( | ||
baseXcframeworkPath, | ||
changedDartXcframeworkPath, | ||
); | ||
expect(differ.assetsFileSetDiff(fileSetDiff), isEmpty); | ||
expect(differ.dartFileSetDiff(fileSetDiff), isNotEmpty); | ||
expect(differ.nativeFileSetDiff(fileSetDiff), isEmpty); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.