From 342b7da23e17b6566df6ad8071446b47fca5f05f Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Mon, 27 Jan 2025 15:43:51 -0800 Subject: [PATCH 1/2] [tool] Add --xcode-warnings-exceptions flag --- .ci/targets/ios_platform_tests.yaml | 6 +- .ci/targets/macos_platform_tests.yaml | 4 +- script/configs/xcode_warnings_exceptions.yaml | 3 + script/tool/lib/src/native_test_command.dart | 17 +- .../tool/lib/src/xcode_analyze_command.dart | 15 +- .../tool/test/native_test_command_test.dart | 99 ++++++++++- .../tool/test/xcode_analyze_command_test.dart | 168 ++++++++++++++++++ 7 files changed, 303 insertions(+), 9 deletions(-) create mode 100644 script/configs/xcode_warnings_exceptions.yaml diff --git a/.ci/targets/ios_platform_tests.yaml b/.ci/targets/ios_platform_tests.yaml index bc962e41ece..a1694675a0b 100644 --- a/.ci/targets/ios_platform_tests.yaml +++ b/.ci/targets/ios_platform_tests.yaml @@ -14,15 +14,15 @@ tasks: args: ["build-examples", "--ios", "--swift-package-manager"] - name: xcode analyze script: .ci/scripts/tool_runner.sh - args: ["xcode-analyze", "--ios"] + args: ["xcode-analyze", "--ios", "--xcode-warnings-exceptions=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"] + 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"] - name: native test script: .ci/scripts/tool_runner.sh # Simulator name and version must match name and version in create_simulator.sh - args: ["native-test", "--ios", "--ios-destination", "platform=iOS Simulator,name=Flutter-iPhone,OS=17.0"] + args: ["native-test", "--ios", "--ios-destination", "platform=iOS Simulator,name=Flutter-iPhone,OS=17.0", "--xcode-warnings-exceptions=script/configs/xcode_warnings_exceptions.yaml"] - name: boot simulator # Ensure simulator is still booted script: .ci/scripts/boot_simulator.sh diff --git a/.ci/targets/macos_platform_tests.yaml b/.ci/targets/macos_platform_tests.yaml index c3a5d83b11e..e9bfb58bb01 100644 --- a/.ci/targets/macos_platform_tests.yaml +++ b/.ci/targets/macos_platform_tests.yaml @@ -11,11 +11,11 @@ tasks: args: ["build-examples", "--macos", "--swift-package-manager"] - name: xcode analyze script: .ci/scripts/tool_runner.sh - args: ["xcode-analyze", "--macos"] + args: ["xcode-analyze", "--macos", "--xcode-warnings-exceptions=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"] + 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"] - name: native test script: .ci/scripts/tool_runner.sh args: ["native-test", "--macos"] diff --git a/script/configs/xcode_warnings_exceptions.yaml b/script/configs/xcode_warnings_exceptions.yaml new file mode 100644 index 00000000000..61f63f5108d --- /dev/null +++ b/script/configs/xcode_warnings_exceptions.yaml @@ -0,0 +1,3 @@ +# The list of plugins that are allowed to have Xcode warnings. +# +# All entries here should have an explanation for why they are here. diff --git a/script/tool/lib/src/native_test_command.dart b/script/tool/lib/src/native_test_command.dart index 47fd5799876..508071c57e3 100644 --- a/script/tool/lib/src/native_test_command.dart +++ b/script/tool/lib/src/native_test_command.dart @@ -21,6 +21,8 @@ const String _integrationTestFlag = 'integration'; const String _iOSDestinationFlag = 'ios-destination'; +const String _xcodeWarningsExceptionsFlag = 'xcode-warnings-exceptions'; + const int _exitNoIOSSimulators = 3; /// The error message logged when a FlutterTestRunner test is not annotated with @@ -65,6 +67,14 @@ class NativeTestCommand extends PackageLoopingCommand { help: 'Runs native unit tests', defaultsTo: true); argParser.addFlag(_integrationTestFlag, help: 'Runs native integration (UI) tests', defaultsTo: true); + + argParser.addMultiOption( + _xcodeWarningsExceptionsFlag, + 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: [], + ); } // The ABI of the host. @@ -100,6 +110,8 @@ this command. List _requestedPlatforms = []; + Set _xcodeWarningsExceptions = {}; + @override Future initializeRun() async { _platforms = { @@ -151,6 +163,8 @@ this command. destination, ]; } + + _xcodeWarningsExceptions = getYamlListArg(_xcodeWarningsExceptionsFlag); } @override @@ -487,7 +501,8 @@ this command. extraFlags: [ if (testTarget != null) '-only-testing:$testTarget', ...extraFlags, - 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', + if (!_xcodeWarningsExceptions.contains(plugin.directory.basename)) + 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', ], ); diff --git a/script/tool/lib/src/xcode_analyze_command.dart b/script/tool/lib/src/xcode_analyze_command.dart index ba4b3fb5e95..757b416e28e 100644 --- a/script/tool/lib/src/xcode_analyze_command.dart +++ b/script/tool/lib/src/xcode_analyze_command.dart @@ -28,10 +28,18 @@ 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: [], + ); } static const String _minIOSVersionArg = 'ios-min-version'; static const String _minMacOSVersionArg = 'macos-min-version'; + static const String _xcodeWarningsExceptionsArg = 'xcode-warnings-exceptions'; final Xcode _xcode; @@ -45,12 +53,16 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand { final String description = 'Runs Xcode analysis on the iOS and/or macOS example apps.'; + Set _xcodeWarningsExceptions = {}; + @override Future initializeRun() async { if (!(getBoolArg(platformIOS) || getBoolArg(platformMacOS))) { printError('At least one platform flag must be provided.'); throw ToolExit(exitInvalidArguments); } + + _xcodeWarningsExceptions = getYamlListArg(_xcodeWarningsExceptionsArg); } @override @@ -121,7 +133,8 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand { hostPlatform: platform, extraFlags: [ ...extraFlags, - 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', + if (!_xcodeWarningsExceptions.contains(plugin.directory.basename)) + 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', ], ); if (exitCode == 0) { diff --git a/script/tool/test/native_test_command_test.dart b/script/tool/test/native_test_command_test.dart index 02cd5c2c43e..cdaa2a748bd 100644 --- a/script/tool/test/native_test_command_test.dart +++ b/script/tool/test/native_test_command_test.dart @@ -27,6 +27,8 @@ const String _androidIntegrationTestFilter = '-Pandroid.testInstrumentationRunnerArguments.' 'notAnnotation=io.flutter.plugins.DartIntegrationTest'; +const String _simulatorDeviceId = '1E76A0FD-38AC-4537-A989-EA639D7D012A'; + final Map _kDeviceListMap = { 'runtimes': >[ { @@ -137,6 +139,7 @@ void main() { String platform, { String? destination, List extraFlags = const [], + bool treatWarningsAsErrors = true, }) { return ProcessCall( 'xcrun', @@ -152,7 +155,7 @@ void main() { 'Debug', if (destination != null) ...['-destination', destination], ...extraFlags, - 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', + if (treatWarningsAsErrors) 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', ], package.path); } @@ -349,7 +352,7 @@ void main() { null), getTargetCheckCall(pluginExampleDirectory, 'ios'), getRunTestCall(pluginExampleDirectory, 'ios', - destination: 'id=1E76A0FD-38AC-4537-A989-EA639D7D012A'), + destination: 'id=$_simulatorDeviceId'), ])); }); }); @@ -1450,6 +1453,98 @@ public class FlutterActivityTest { getTargetCheckCall(pluginExampleDirectory, 'macos'), ])); }); + + test('Xcode warnings exceptions list', () async { + final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir, + platformSupport: { + platformIOS: const PlatformDetails(PlatformSupport.inline) + }); + + final Directory pluginExampleDirectory = getExampleDir(plugin); + + processRunner.mockProcessesForExecutable['xcrun'] = [ + FakeProcessInfo(MockProcess(stdout: jsonEncode(_kDeviceListMap)), + ['simctl', 'list']), + getMockXcodebuildListProcess( + ['RunnerTests', 'RunnerUITests']), + ]; + + await runCapturingPrint(runner, [ + 'native-test', + '--ios', + '--xcode-warnings-exceptions=plugin' + ]); + + expect( + processRunner.recordedCalls, + contains( + getRunTestCall(pluginExampleDirectory, 'ios', + destination: 'id=$_simulatorDeviceId', + treatWarningsAsErrors: false), + )); + }); + + test('Xcode warnings exceptions file', () async { + final File configFile = packagesDir.childFile('exceptions.yaml'); + await configFile.writeAsString('- plugin'); + final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir, + platformSupport: { + platformIOS: const PlatformDetails(PlatformSupport.inline) + }); + + final Directory pluginExampleDirectory = getExampleDir(plugin); + + processRunner.mockProcessesForExecutable['xcrun'] = [ + FakeProcessInfo(MockProcess(stdout: jsonEncode(_kDeviceListMap)), + ['simctl', 'list']), + getMockXcodebuildListProcess( + ['RunnerTests', 'RunnerUITests']), + ]; + + await runCapturingPrint(runner, [ + 'native-test', + '--ios', + '--xcode-warnings-exceptions=${configFile.path}' + ]); + + expect( + processRunner.recordedCalls, + contains( + getRunTestCall(pluginExampleDirectory, 'ios', + destination: 'id=$_simulatorDeviceId', + treatWarningsAsErrors: false), + )); + }); + + test('treat warnings as errors if plugin not on exceptions list', + () async { + final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir, + platformSupport: { + platformIOS: const PlatformDetails(PlatformSupport.inline) + }); + + final Directory pluginExampleDirectory = getExampleDir(plugin); + + processRunner.mockProcessesForExecutable['xcrun'] = [ + FakeProcessInfo(MockProcess(stdout: jsonEncode(_kDeviceListMap)), + ['simctl', 'list']), + getMockXcodebuildListProcess( + ['RunnerTests', 'RunnerUITests']), + ]; + + await runCapturingPrint(runner, [ + 'native-test', + '--ios', + '--xcode-warnings-exceptions=foo,bar' + ]); + + expect( + processRunner.recordedCalls, + contains( + getRunTestCall(pluginExampleDirectory, 'ios', + destination: 'id=$_simulatorDeviceId'), + )); + }); }); group('multiplatform', () { diff --git a/script/tool/test/xcode_analyze_command_test.dart b/script/tool/test/xcode_analyze_command_test.dart index cd4fb7306c4..519bc3fb423 100644 --- a/script/tool/test/xcode_analyze_command_test.dart +++ b/script/tool/test/xcode_analyze_command_test.dart @@ -485,6 +485,174 @@ void main() { expect(processRunner.recordedCalls, orderedEquals([])); }); + + test('Xcode warnings exceptions list', () async { + final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir, + platformSupport: { + platformIOS: const PlatformDetails(PlatformSupport.inline), + platformMacOS: const PlatformDetails(PlatformSupport.inline), + }); + + final Directory pluginExampleDirectory = getExampleDir(plugin); + + await runCapturingPrint(runner, [ + 'xcode-analyze', + '--ios', + '--macos', + '--xcode-warnings-exceptions=plugin' + ]); + + expect( + processRunner.recordedCalls, + orderedEquals([ + ProcessCall( + 'xcrun', + const [ + 'xcodebuild', + 'clean', + 'analyze', + '-workspace', + 'ios/Runner.xcworkspace', + '-scheme', + 'Runner', + '-configuration', + 'Debug', + '-destination', + 'generic/platform=iOS Simulator', + ], + pluginExampleDirectory.path), + ProcessCall( + 'xcrun', + const [ + '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: { + platformIOS: const PlatformDetails(PlatformSupport.inline), + platformMacOS: const PlatformDetails(PlatformSupport.inline), + }); + + final Directory pluginExampleDirectory = getExampleDir(plugin); + + await runCapturingPrint(runner, [ + 'xcode-analyze', + '--ios', + '--macos', + '--xcode-warnings-exceptions=${configFile.path}' + ]); + + expect( + processRunner.recordedCalls, + orderedEquals([ + ProcessCall( + 'xcrun', + const [ + 'xcodebuild', + 'clean', + 'analyze', + '-workspace', + 'ios/Runner.xcworkspace', + '-scheme', + 'Runner', + '-configuration', + 'Debug', + '-destination', + 'generic/platform=iOS Simulator', + ], + pluginExampleDirectory.path), + ProcessCall( + 'xcrun', + const [ + '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: { + platformIOS: const PlatformDetails(PlatformSupport.inline), + platformMacOS: const PlatformDetails(PlatformSupport.inline), + }); + + final Directory pluginExampleDirectory = getExampleDir(plugin); + + final List output = await runCapturingPrint(runner, [ + 'xcode-analyze', + '--ios', + '--macos', + '--xcode-warnings-exceptions=foo,bar' + ]); + + expect( + output, + containsAll([ + contains('plugin/example (iOS) passed analysis.'), + contains('plugin/example (macOS) passed analysis.'), + ])); + + expect( + processRunner.recordedCalls, + orderedEquals([ + ProcessCall( + 'xcrun', + const [ + '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 [ + 'xcodebuild', + 'clean', + 'analyze', + '-workspace', + 'macos/Runner.xcworkspace', + '-scheme', + 'Runner', + '-configuration', + 'Debug', + 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', + ], + pluginExampleDirectory.path), + ])); + }); }); }); } From f5d54a08910ee3969a74e3773bb95ee9dcdf3e3d Mon Sep 17 00:00:00 2001 From: Loic Sharma Date: Thu, 30 Jan 2025 14:19:24 -0800 Subject: [PATCH 2/2] Feedback: Use --exclude for xcode-analyze --- .ci/targets/ios_platform_tests.yaml | 4 +- .ci/targets/macos_platform_tests.yaml | 6 +- script/configs/xcode_warnings_exceptions.yaml | 4 +- .../tool/lib/src/xcode_analyze_command.dart | 15 +- .../tool/test/xcode_analyze_command_test.dart | 168 ------------------ 5 files changed, 9 insertions(+), 188 deletions(-) diff --git a/.ci/targets/ios_platform_tests.yaml b/.ci/targets/ios_platform_tests.yaml index a1694675a0b..90b61b1a0df 100644 --- a/.ci/targets/ios_platform_tests.yaml +++ b/.ci/targets/ios_platform_tests.yaml @@ -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 diff --git a/.ci/targets/macos_platform_tests.yaml b/.ci/targets/macos_platform_tests.yaml index e9bfb58bb01..55701d14f0e 100644 --- a/.ci/targets/macos_platform_tests.yaml +++ b/.ci/targets/macos_platform_tests.yaml @@ -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"] diff --git a/script/configs/xcode_warnings_exceptions.yaml b/script/configs/xcode_warnings_exceptions.yaml index 61f63f5108d..0c51c4abcf4 100644 --- a/script/configs/xcode_warnings_exceptions.yaml +++ b/script/configs/xcode_warnings_exceptions.yaml @@ -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. diff --git a/script/tool/lib/src/xcode_analyze_command.dart b/script/tool/lib/src/xcode_analyze_command.dart index 757b416e28e..ba4b3fb5e95 100644 --- a/script/tool/lib/src/xcode_analyze_command.dart +++ b/script/tool/lib/src/xcode_analyze_command.dart @@ -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: [], - ); } static const String _minIOSVersionArg = 'ios-min-version'; static const String _minMacOSVersionArg = 'macos-min-version'; - static const String _xcodeWarningsExceptionsArg = 'xcode-warnings-exceptions'; final Xcode _xcode; @@ -53,16 +45,12 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand { final String description = 'Runs Xcode analysis on the iOS and/or macOS example apps.'; - Set _xcodeWarningsExceptions = {}; - @override Future initializeRun() async { if (!(getBoolArg(platformIOS) || getBoolArg(platformMacOS))) { printError('At least one platform flag must be provided.'); throw ToolExit(exitInvalidArguments); } - - _xcodeWarningsExceptions = getYamlListArg(_xcodeWarningsExceptionsArg); } @override @@ -133,8 +121,7 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand { hostPlatform: platform, extraFlags: [ ...extraFlags, - if (!_xcodeWarningsExceptions.contains(plugin.directory.basename)) - 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', + 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', ], ); if (exitCode == 0) { diff --git a/script/tool/test/xcode_analyze_command_test.dart b/script/tool/test/xcode_analyze_command_test.dart index 519bc3fb423..cd4fb7306c4 100644 --- a/script/tool/test/xcode_analyze_command_test.dart +++ b/script/tool/test/xcode_analyze_command_test.dart @@ -485,174 +485,6 @@ void main() { expect(processRunner.recordedCalls, orderedEquals([])); }); - - test('Xcode warnings exceptions list', () async { - final RepositoryPackage plugin = createFakePlugin('plugin', packagesDir, - platformSupport: { - platformIOS: const PlatformDetails(PlatformSupport.inline), - platformMacOS: const PlatformDetails(PlatformSupport.inline), - }); - - final Directory pluginExampleDirectory = getExampleDir(plugin); - - await runCapturingPrint(runner, [ - 'xcode-analyze', - '--ios', - '--macos', - '--xcode-warnings-exceptions=plugin' - ]); - - expect( - processRunner.recordedCalls, - orderedEquals([ - ProcessCall( - 'xcrun', - const [ - 'xcodebuild', - 'clean', - 'analyze', - '-workspace', - 'ios/Runner.xcworkspace', - '-scheme', - 'Runner', - '-configuration', - 'Debug', - '-destination', - 'generic/platform=iOS Simulator', - ], - pluginExampleDirectory.path), - ProcessCall( - 'xcrun', - const [ - '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: { - platformIOS: const PlatformDetails(PlatformSupport.inline), - platformMacOS: const PlatformDetails(PlatformSupport.inline), - }); - - final Directory pluginExampleDirectory = getExampleDir(plugin); - - await runCapturingPrint(runner, [ - 'xcode-analyze', - '--ios', - '--macos', - '--xcode-warnings-exceptions=${configFile.path}' - ]); - - expect( - processRunner.recordedCalls, - orderedEquals([ - ProcessCall( - 'xcrun', - const [ - 'xcodebuild', - 'clean', - 'analyze', - '-workspace', - 'ios/Runner.xcworkspace', - '-scheme', - 'Runner', - '-configuration', - 'Debug', - '-destination', - 'generic/platform=iOS Simulator', - ], - pluginExampleDirectory.path), - ProcessCall( - 'xcrun', - const [ - '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: { - platformIOS: const PlatformDetails(PlatformSupport.inline), - platformMacOS: const PlatformDetails(PlatformSupport.inline), - }); - - final Directory pluginExampleDirectory = getExampleDir(plugin); - - final List output = await runCapturingPrint(runner, [ - 'xcode-analyze', - '--ios', - '--macos', - '--xcode-warnings-exceptions=foo,bar' - ]); - - expect( - output, - containsAll([ - contains('plugin/example (iOS) passed analysis.'), - contains('plugin/example (macOS) passed analysis.'), - ])); - - expect( - processRunner.recordedCalls, - orderedEquals([ - ProcessCall( - 'xcrun', - const [ - '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 [ - 'xcodebuild', - 'clean', - 'analyze', - '-workspace', - 'macos/Runner.xcworkspace', - '-scheme', - 'Runner', - '-configuration', - 'Debug', - 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', - ], - pluginExampleDirectory.path), - ])); - }); }); }); }