Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions script/tool/lib/src/license_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const Set<String> _ignoreSuffixList = <String>{
// Full basenames of files to ignore.
const Set<String> _ignoredFullBasenameList = <String>{
'resource.h', // Generated by VS.
'Package.swift', // Swift Package Manifest file.
};

// Copyright and license regexes for third-party code.
Expand Down
6 changes: 4 additions & 2 deletions script/tool/lib/src/podspec_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ class PodspecCheckCommand extends PackageLoopingCommand {
}

/// Returns true if there is any iOS plugin implementation code written in
/// Swift.
/// Swift. Skips files named "Package.swift", which is a Swift Pacakge Manager
/// manifest file and does not mean the plugin is written in Swift.
Future<bool> _hasIOSSwiftCode(RepositoryPackage package) async {
return getFilesForPackage(package).any((File entity) {
final String relativePath =
Expand All @@ -171,7 +172,8 @@ class PodspecCheckCommand extends PackageLoopingCommand {
return false;
}
final String filePath = entity.path;
return path.extension(filePath) == '.swift';
return entity.basename != 'Package.swift' &&
path.extension(filePath) == '.swift';
});
}

Expand Down
1 change: 1 addition & 0 deletions script/tool/test/license_check_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void main() {
'foo.mocks.dart',
// Ignored files.
'resource.h',
'Package.swift',
];

for (final String name in ignoredFiles) {
Expand Down
31 changes: 29 additions & 2 deletions script/tool/test/podspec_check_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,14 @@ void main() {

test('fails if an iOS Swift plugin is missing the search paths workaround',
() async {
final RepositoryPackage plugin = createFakePlugin('plugin1', packagesDir,
extraFiles: <String>['ios/Classes/SomeSwift.swift']);
final RepositoryPackage plugin = createFakePlugin(
'plugin1',
packagesDir,
extraFiles: <String>[
'ios/Classes/SomeSwift.swift',
'ios/Package.swift',
],
);
_writeFakePodspec(plugin, 'ios');

Error? commandError;
Expand Down Expand Up @@ -378,6 +384,27 @@ void main() {
));
});

test('does not require the search paths workaround for Package.swift',
() async {
final RepositoryPackage plugin = createFakePlugin(
'plugin1',
packagesDir,
extraFiles: <String>['ios/Package.swift'],
);
_writeFakePodspec(plugin, 'ios');

final List<String> output =
await runCapturingPrint(runner, <String>['podspec-check']);

expect(
output,
containsAllInOrder(
<Matcher>[
contains('Ran for 1 package(s)'),
],
));
});

test('does not require the search paths workaround for macOS plugins',
() async {
final RepositoryPackage plugin = createFakePlugin('plugin1', packagesDir,
Expand Down