Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add license check back, make podspec check more specific
  • Loading branch information
vashworth committed Apr 30, 2024
commit 34e5c85c16bb3b9bd71426e3e61a71016cd6d78c
1 change: 0 additions & 1 deletion script/tool/lib/src/license_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ 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
7 changes: 6 additions & 1 deletion script/tool/lib/src/podspec_check_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ class PodspecCheckCommand extends PackageLoopingCommand {
/// 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 {
final String iosSwiftPackageManifestPath = package
.platformDirectory(FlutterPlatform.ios)
.childDirectory(package.displayName)
.childFile('Package.swift')
.path;
return getFilesForPackage(package).any((File entity) {
final String relativePath =
getRelativePosixPath(entity, from: package.directory);
Expand All @@ -172,7 +177,7 @@ class PodspecCheckCommand extends PackageLoopingCommand {
return false;
}
final String filePath = entity.path;
return entity.basename != 'Package.swift' &&
return filePath != iosSwiftPackageManifestPath &&
path.extension(filePath) == '.swift';
});
}
Expand Down
18 changes: 17 additions & 1 deletion script/tool/test/license_check_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ void main() {
'foo.mocks.dart',
// Ignored files.
'resource.h',
'Package.swift',
];

for (final String name in ignoredFiles) {
Expand Down Expand Up @@ -545,6 +544,23 @@ void main() {
contains(' third_party/bad.cc'),
]));
});

test('passes if Package.swift has license blocks', () async {
final File checked = root.childFile('Package.swift');
checked.createSync();
writeLicense(checked, prefix: '// swift-tools-version: 5.9\n');

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

// Sanity check that the test did actually check a file.
expect(
output,
containsAllInOrder(<Matcher>[
contains('Checking Package.swift'),
contains('All files passed validation!'),
]));
});
});
}

Expand Down
6 changes: 3 additions & 3 deletions script/tool/test/podspec_check_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void main() {
packagesDir,
extraFiles: <String>[
'ios/Classes/SomeSwift.swift',
'ios/Package.swift',
'ios/plugin1/Package.swift',
],
);
_writeFakePodspec(plugin, 'ios');
Expand Down Expand Up @@ -384,12 +384,12 @@ void main() {
));
});

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

Expand Down