Skip to content

Commit 95c88f8

Browse files
[tool] Don't lint Flutter shim podspecs (flutter#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.
1 parent 21c2ebb commit 95c88f8

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

script/tool/lib/src/podspec_check_command.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ class PodspecCheckCommand extends PackageLoopingCommand {
102102
Future<List<File>> _podspecsToLint(RepositoryPackage package) async {
103103
final List<File> podspecs =
104104
await getFilesForPackage(package).where((File entity) {
105-
final String filePath = entity.path;
106-
return path.extension(filePath) == '.podspec';
105+
final String filename = entity.basename;
106+
return path.extension(filename) == '.podspec' &&
107+
filename != 'Flutter.podspec' &&
108+
filename != 'FlutterMacOS.podspec';
107109
}).toList();
108110

109111
podspecs.sort((File a, File b) => a.basename.compareTo(b.basename));

script/tool/test/podspec_check_command_test.dart

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,60 @@ void main() {
171171
expect(output, contains('Bar'));
172172
});
173173

174+
test('skips shim podspecs for the Flutter framework', () async {
175+
final RepositoryPackage plugin = createFakePlugin(
176+
'plugin1',
177+
packagesDir,
178+
extraFiles: <String>[
179+
'example/ios/Flutter/Flutter.podspec',
180+
'example/macos/Flutter/ephemeral/FlutterMacOS.podspec',
181+
],
182+
);
183+
_writeFakePodspec(plugin, 'macos');
184+
185+
final List<String> output =
186+
await runCapturingPrint(runner, <String>['podspec-check']);
187+
188+
expect(output, isNot(contains('FlutterMacOS.podspec')));
189+
expect(
190+
processRunner.recordedCalls,
191+
orderedEquals(<ProcessCall>[
192+
ProcessCall('which', const <String>['pod'], packagesDir.path),
193+
ProcessCall(
194+
'pod',
195+
<String>[
196+
'lib',
197+
'lint',
198+
plugin
199+
.platformDirectory(FlutterPlatform.macos)
200+
.childFile('plugin1.podspec')
201+
.path,
202+
'--configuration=Debug',
203+
'--skip-tests',
204+
'--allow-warnings',
205+
'--use-modular-headers',
206+
'--use-libraries'
207+
],
208+
packagesDir.path),
209+
ProcessCall(
210+
'pod',
211+
<String>[
212+
'lib',
213+
'lint',
214+
plugin
215+
.platformDirectory(FlutterPlatform.macos)
216+
.childFile('plugin1.podspec')
217+
.path,
218+
'--configuration=Debug',
219+
'--skip-tests',
220+
'--allow-warnings',
221+
'--use-modular-headers',
222+
],
223+
packagesDir.path),
224+
]),
225+
);
226+
});
227+
174228
test('fails if pod is missing', () async {
175229
final RepositoryPackage plugin = createFakePlugin('plugin1', packagesDir);
176230
_writeFakePodspec(plugin, 'ios');

0 commit comments

Comments
 (0)