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
Feedback: Use --exclude for xcode-analyze
  • Loading branch information
loic-sharma committed Jan 30, 2025
commit f5d54a08910ee3969a74e3773bb95ee9dcdf3e3d
4 changes: 2 additions & 2 deletions .ci/targets/ios_platform_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ tasks:
args: ["build-examples", "--ios", "--swift-package-manager"]
- name: xcode analyze
script: .ci/scripts/tool_runner.sh
args: ["xcode-analyze", "--ios", "--xcode-warnings-exceptions=script/configs/xcode_warnings_exceptions.yaml"]
args: ["xcode-analyze", "--ios", "--exclude=script/configs/xcode_warnings_exceptions.yaml"]
- name: xcode analyze deprecation
# Ensure we don't accidentally introduce deprecated code.
script: .ci/scripts/tool_runner.sh
args: ["xcode-analyze", "--ios", "--ios-min-version=14.0", "--exclude=script/configs/exclude_xcode_deprecation.yaml", "--xcode-warnings-exceptions=script/configs/xcode_warnings_exceptions.yaml"]
args: ["xcode-analyze", "--ios", "--ios-min-version=14.0", "--exclude=script/configs/exclude_xcode_deprecation.yaml,script/configs/xcode_warnings_exceptions.yaml"]
- name: native test
script: .ci/scripts/tool_runner.sh
# Simulator name and version must match name and version in create_simulator.sh
Expand Down
6 changes: 3 additions & 3 deletions .ci/targets/macos_platform_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ tasks:
args: ["build-examples", "--macos", "--swift-package-manager"]
- name: xcode analyze
script: .ci/scripts/tool_runner.sh
args: ["xcode-analyze", "--macos", "--xcode-warnings-exceptions=script/configs/xcode_warnings_exceptions.yaml"]
args: ["xcode-analyze", "--macos", "--exclude=script/configs/xcode_warnings_exceptions.yaml"]
- name: xcode analyze deprecation
# Ensure we don't accidentally introduce deprecated code.
script: .ci/scripts/tool_runner.sh
args: ["xcode-analyze", "--macos", "--macos-min-version=14.0", "--exclude=script/configs/exclude_xcode_deprecation.yaml", "--xcode-warnings-exceptions=script/configs/xcode_warnings_exceptions.yaml"]
args: ["xcode-analyze", "--macos", "--macos-min-version=14.0", "--exclude=script/configs/exclude_xcode_deprecation.yaml,script/configs/xcode_warnings_exceptions.yaml"]
- name: native test
script: .ci/scripts/tool_runner.sh
args: ["native-test", "--macos"]
args: ["native-test", "--macos", "--xcode-warnings-exceptions=script/configs/xcode_warnings_exceptions.yaml"]
- name: drive examples
script: .ci/scripts/tool_runner.sh
args: ["drive-examples", "--macos", "--exclude=script/configs/exclude_integration_macos.yaml"]
4 changes: 3 additions & 1 deletion script/configs/xcode_warnings_exceptions.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# The list of plugins that are allowed to have Xcode warnings.
# The list of plugins that are known to produce Xcode warnings.
# These should be excluded from Xcode analysis and "treat warnings as errors"
# should be disabled when running their native tests.
#
# All entries here should have an explanation for why they are here.
15 changes: 1 addition & 14 deletions script/tool/lib/src/xcode_analyze_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,10 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
'Sets the minimum macOS deployment version to use when compiling, '
'overriding the default minimum version. This can be used to find '
'deprecation warnings that will affect the plugin in the future.');
argParser.addMultiOption(
_xcodeWarningsExceptionsArg,
help: 'A list of packages that are allowed to have Xcode warnings.\n\n'
'Alternately, a list of one or more YAML files that contain a list '
'of packages to allow Xcode warnings.',
defaultsTo: <String>[],
);
}

static const String _minIOSVersionArg = 'ios-min-version';
static const String _minMacOSVersionArg = 'macos-min-version';
static const String _xcodeWarningsExceptionsArg = 'xcode-warnings-exceptions';

final Xcode _xcode;

Expand All @@ -53,16 +45,12 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
final String description =
'Runs Xcode analysis on the iOS and/or macOS example apps.';

Set<String> _xcodeWarningsExceptions = <String>{};

@override
Future<void> initializeRun() async {
if (!(getBoolArg(platformIOS) || getBoolArg(platformMacOS))) {
printError('At least one platform flag must be provided.');
throw ToolExit(exitInvalidArguments);
}

_xcodeWarningsExceptions = getYamlListArg(_xcodeWarningsExceptionsArg);
}

@override
Expand Down Expand Up @@ -133,8 +121,7 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand {
hostPlatform: platform,
extraFlags: <String>[
...extraFlags,
if (!_xcodeWarningsExceptions.contains(plugin.directory.basename))
'GCC_TREAT_WARNINGS_AS_ERRORS=YES',
'GCC_TREAT_WARNINGS_AS_ERRORS=YES',
],
);
if (exitCode == 0) {
Expand Down
168 changes: 0 additions & 168 deletions script/tool/test/xcode_analyze_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -485,174 +485,6 @@ void main() {

expect(processRunner.recordedCalls, orderedEquals(<ProcessCall>[]));
});

test('Xcode warnings exceptions list', () async {
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
platformSupport: <String, PlatformDetails>{
platformIOS: const PlatformDetails(PlatformSupport.inline),
platformMacOS: const PlatformDetails(PlatformSupport.inline),
});

final Directory pluginExampleDirectory = getExampleDir(plugin);

await runCapturingPrint(runner, <String>[
'xcode-analyze',
'--ios',
'--macos',
'--xcode-warnings-exceptions=plugin'
]);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
'xcrun',
const <String>[
'xcodebuild',
'clean',
'analyze',
'-workspace',
'ios/Runner.xcworkspace',
'-scheme',
'Runner',
'-configuration',
'Debug',
'-destination',
'generic/platform=iOS Simulator',
],
pluginExampleDirectory.path),
ProcessCall(
'xcrun',
const <String>[
'xcodebuild',
'clean',
'analyze',
'-workspace',
'macos/Runner.xcworkspace',
'-scheme',
'Runner',
'-configuration',
'Debug',
],
pluginExampleDirectory.path),
]));
});

test('Xcode warnings exceptions file', () async {
final File configFile = packagesDir.childFile('exceptions.yaml');
await configFile.writeAsString('- plugin');
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
platformSupport: <String, PlatformDetails>{
platformIOS: const PlatformDetails(PlatformSupport.inline),
platformMacOS: const PlatformDetails(PlatformSupport.inline),
});

final Directory pluginExampleDirectory = getExampleDir(plugin);

await runCapturingPrint(runner, <String>[
'xcode-analyze',
'--ios',
'--macos',
'--xcode-warnings-exceptions=${configFile.path}'
]);

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
'xcrun',
const <String>[
'xcodebuild',
'clean',
'analyze',
'-workspace',
'ios/Runner.xcworkspace',
'-scheme',
'Runner',
'-configuration',
'Debug',
'-destination',
'generic/platform=iOS Simulator',
],
pluginExampleDirectory.path),
ProcessCall(
'xcrun',
const <String>[
'xcodebuild',
'clean',
'analyze',
'-workspace',
'macos/Runner.xcworkspace',
'-scheme',
'Runner',
'-configuration',
'Debug',
],
pluginExampleDirectory.path),
]));
});

test('treat warnings as errors if plugin not on exceptions list',
() async {
final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir,
platformSupport: <String, PlatformDetails>{
platformIOS: const PlatformDetails(PlatformSupport.inline),
platformMacOS: const PlatformDetails(PlatformSupport.inline),
});

final Directory pluginExampleDirectory = getExampleDir(plugin);

final List<String> output = await runCapturingPrint(runner, <String>[
'xcode-analyze',
'--ios',
'--macos',
'--xcode-warnings-exceptions=foo,bar'
]);

expect(
output,
containsAll(<Matcher>[
contains('plugin/example (iOS) passed analysis.'),
contains('plugin/example (macOS) passed analysis.'),
]));

expect(
processRunner.recordedCalls,
orderedEquals(<ProcessCall>[
ProcessCall(
'xcrun',
const <String>[
'xcodebuild',
'clean',
'analyze',
'-workspace',
'ios/Runner.xcworkspace',
'-scheme',
'Runner',
'-configuration',
'Debug',
'-destination',
'generic/platform=iOS Simulator',
'GCC_TREAT_WARNINGS_AS_ERRORS=YES',
],
pluginExampleDirectory.path),
ProcessCall(
'xcrun',
const <String>[
'xcodebuild',
'clean',
'analyze',
'-workspace',
'macos/Runner.xcworkspace',
'-scheme',
'Runner',
'-configuration',
'Debug',
'GCC_TREAT_WARNINGS_AS_ERRORS=YES',
],
pluginExampleDirectory.path),
]));
});
});
});
}