mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 23:03:11 +08:00
[tool] Don't lint Flutter shim podspecs (#5007)
The Flutter build process creates podspecs that are just shims pointing to the local Flutter framework, and which don't pass the linter since they aren't intended for publishing. When finding podspecs to lint, skip those. This avoids incorrect failures when running on a tree that isn't clean (in particular, where macOS and/or iOS builds have happened), which is very common locally.
This commit is contained in:
@ -102,8 +102,10 @@ class PodspecCheckCommand extends PackageLoopingCommand {
|
|||||||
Future<List<File>> _podspecsToLint(RepositoryPackage package) async {
|
Future<List<File>> _podspecsToLint(RepositoryPackage package) async {
|
||||||
final List<File> podspecs =
|
final List<File> podspecs =
|
||||||
await getFilesForPackage(package).where((File entity) {
|
await getFilesForPackage(package).where((File entity) {
|
||||||
final String filePath = entity.path;
|
final String filename = entity.basename;
|
||||||
return path.extension(filePath) == '.podspec';
|
return path.extension(filename) == '.podspec' &&
|
||||||
|
filename != 'Flutter.podspec' &&
|
||||||
|
filename != 'FlutterMacOS.podspec';
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
podspecs.sort((File a, File b) => a.basename.compareTo(b.basename));
|
podspecs.sort((File a, File b) => a.basename.compareTo(b.basename));
|
||||||
|
@ -171,6 +171,60 @@ void main() {
|
|||||||
expect(output, contains('Bar'));
|
expect(output, contains('Bar'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('skips shim podspecs for the Flutter framework', () async {
|
||||||
|
final RepositoryPackage plugin = createFakePlugin(
|
||||||
|
'plugin1',
|
||||||
|
packagesDir,
|
||||||
|
extraFiles: <String>[
|
||||||
|
'example/ios/Flutter/Flutter.podspec',
|
||||||
|
'example/macos/Flutter/ephemeral/FlutterMacOS.podspec',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
_writeFakePodspec(plugin, 'macos');
|
||||||
|
|
||||||
|
final List<String> output =
|
||||||
|
await runCapturingPrint(runner, <String>['podspec-check']);
|
||||||
|
|
||||||
|
expect(output, isNot(contains('FlutterMacOS.podspec')));
|
||||||
|
expect(
|
||||||
|
processRunner.recordedCalls,
|
||||||
|
orderedEquals(<ProcessCall>[
|
||||||
|
ProcessCall('which', const <String>['pod'], packagesDir.path),
|
||||||
|
ProcessCall(
|
||||||
|
'pod',
|
||||||
|
<String>[
|
||||||
|
'lib',
|
||||||
|
'lint',
|
||||||
|
plugin
|
||||||
|
.platformDirectory(FlutterPlatform.macos)
|
||||||
|
.childFile('plugin1.podspec')
|
||||||
|
.path,
|
||||||
|
'--configuration=Debug',
|
||||||
|
'--skip-tests',
|
||||||
|
'--allow-warnings',
|
||||||
|
'--use-modular-headers',
|
||||||
|
'--use-libraries'
|
||||||
|
],
|
||||||
|
packagesDir.path),
|
||||||
|
ProcessCall(
|
||||||
|
'pod',
|
||||||
|
<String>[
|
||||||
|
'lib',
|
||||||
|
'lint',
|
||||||
|
plugin
|
||||||
|
.platformDirectory(FlutterPlatform.macos)
|
||||||
|
.childFile('plugin1.podspec')
|
||||||
|
.path,
|
||||||
|
'--configuration=Debug',
|
||||||
|
'--skip-tests',
|
||||||
|
'--allow-warnings',
|
||||||
|
'--use-modular-headers',
|
||||||
|
],
|
||||||
|
packagesDir.path),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('fails if pod is missing', () async {
|
test('fails if pod is missing', () async {
|
||||||
final RepositoryPackage plugin = createFakePlugin('plugin1', packagesDir);
|
final RepositoryPackage plugin = createFakePlugin('plugin1', packagesDir);
|
||||||
_writeFakePodspec(plugin, 'ios');
|
_writeFakePodspec(plugin, 'ios');
|
||||||
|
Reference in New Issue
Block a user