From 719bb0a5405c7fe9df607d5e79ac5bbdda01e6b4 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 26 Sep 2023 15:09:01 -0400 Subject: [PATCH] [tool] Don't lint Flutter shim podspecs 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. --- .../tool/lib/src/podspec_check_command.dart | 6 ++- .../tool/test/podspec_check_command_test.dart | 54 +++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/script/tool/lib/src/podspec_check_command.dart b/script/tool/lib/src/podspec_check_command.dart index 5968de5eaf8a..9259e0dbb0a7 100644 --- a/script/tool/lib/src/podspec_check_command.dart +++ b/script/tool/lib/src/podspec_check_command.dart @@ -102,8 +102,10 @@ class PodspecCheckCommand extends PackageLoopingCommand { Future> _podspecsToLint(RepositoryPackage package) async { final List podspecs = await getFilesForPackage(package).where((File entity) { - final String filePath = entity.path; - return path.extension(filePath) == '.podspec'; + final String filename = entity.basename; + return path.extension(filename) == '.podspec' && + filename != 'Flutter.podspec' && + filename != 'FlutterMacOS.podspec'; }).toList(); podspecs.sort((File a, File b) => a.basename.compareTo(b.basename)); diff --git a/script/tool/test/podspec_check_command_test.dart b/script/tool/test/podspec_check_command_test.dart index a58154282731..97783cb29b08 100644 --- a/script/tool/test/podspec_check_command_test.dart +++ b/script/tool/test/podspec_check_command_test.dart @@ -171,6 +171,60 @@ void main() { expect(output, contains('Bar')); }); + test('skips shim podspecs for the Flutter framework', () async { + final RepositoryPackage plugin = createFakePlugin( + 'plugin1', + packagesDir, + extraFiles: [ + 'example/ios/Flutter/Flutter.podspec', + 'example/macos/Flutter/ephemeral/FlutterMacOS.podspec', + ], + ); + _writeFakePodspec(plugin, 'macos'); + + final List output = + await runCapturingPrint(runner, ['podspec-check']); + + expect(output, isNot(contains('FlutterMacOS.podspec'))); + expect( + processRunner.recordedCalls, + orderedEquals([ + ProcessCall('which', const ['pod'], packagesDir.path), + ProcessCall( + 'pod', + [ + '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', + [ + '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 { final RepositoryPackage plugin = createFakePlugin('plugin1', packagesDir); _writeFakePodspec(plugin, 'ios');