From 9d2dc119099aafbc28fefb4c68cb068da04a1130 Mon Sep 17 00:00:00 2001 From: Victoria Ashworth Date: Fri, 31 May 2024 16:23:44 -0500 Subject: [PATCH 1/2] Clean Xcode project before analyzing and testing --- script/tool/lib/src/native_test_command.dart | 2 +- script/tool/lib/src/xcode_analyze_command.dart | 2 +- script/tool/test/native_test_command_test.dart | 7 ++++--- script/tool/test/xcode_analyze_command_test.dart | 8 ++++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/script/tool/lib/src/native_test_command.dart b/script/tool/lib/src/native_test_command.dart index f3fd2b7f6c9..8119e409c6c 100644 --- a/script/tool/lib/src/native_test_command.dart +++ b/script/tool/lib/src/native_test_command.dart @@ -465,7 +465,7 @@ this command. _printRunningExampleTestsMessage(example, platform); final int exitCode = await _xcode.runXcodeBuild( example.directory, - actions: ['test'], + actions: ['clean', 'test'], workspace: '${platform.toLowerCase()}/Runner.xcworkspace', scheme: 'Runner', configuration: 'Debug', diff --git a/script/tool/lib/src/xcode_analyze_command.dart b/script/tool/lib/src/xcode_analyze_command.dart index e753ccb21fc..5795e439060 100644 --- a/script/tool/lib/src/xcode_analyze_command.dart +++ b/script/tool/lib/src/xcode_analyze_command.dart @@ -111,7 +111,7 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand { print('Running $platform tests and analyzer for $examplePath...'); final int exitCode = await _xcode.runXcodeBuild( example.directory, - actions: ['analyze'], + actions: ['clean', 'analyze'], workspace: '${platform.toLowerCase()}/Runner.xcworkspace', scheme: 'Runner', configuration: 'Debug', diff --git a/script/tool/test/native_test_command_test.dart b/script/tool/test/native_test_command_test.dart index 993ee86d600..cd3569739e2 100644 --- a/script/tool/test/native_test_command_test.dart +++ b/script/tool/test/native_test_command_test.dart @@ -139,6 +139,7 @@ void main() { 'xcrun', [ 'xcodebuild', + 'clean', 'test', '-workspace', '$platform/Runner.xcworkspace', @@ -220,7 +221,7 @@ void main() { getMockXcodebuildListProcess(['RunnerTests', 'RunnerUITests']), // Exit code 66 from testing indicates no tests. FakeProcessInfo( - MockProcess(exitCode: 66), ['xcodebuild', 'test']), + MockProcess(exitCode: 66), ['xcodebuild', 'clean', 'test']), ]; final List output = await runCapturingPrint( runner, ['native-test', '--macos', '--no-unit']); @@ -1469,11 +1470,11 @@ public class FlutterActivityTest { getMockXcodebuildListProcess( ['RunnerTests', 'RunnerUITests']), // iOS list FakeProcessInfo( - MockProcess(), ['xcodebuild', 'test']), // iOS run + MockProcess(), ['xcodebuild', 'clean', 'test']), // iOS run getMockXcodebuildListProcess( ['RunnerTests', 'RunnerUITests']), // macOS list FakeProcessInfo( - MockProcess(), ['xcodebuild', 'test']), // macOS run + MockProcess(), ['xcodebuild', 'clean', 'test']), // macOS run ]; final List output = await runCapturingPrint(runner, [ diff --git a/script/tool/test/xcode_analyze_command_test.dart b/script/tool/test/xcode_analyze_command_test.dart index 2caf906fc6a..cd4fb7306c4 100644 --- a/script/tool/test/xcode_analyze_command_test.dart +++ b/script/tool/test/xcode_analyze_command_test.dart @@ -106,6 +106,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'ios/Runner.xcworkspace', @@ -146,6 +147,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'ios/Runner.xcworkspace', @@ -244,6 +246,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'macos/Runner.xcworkspace', @@ -278,6 +281,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'macos/Runner.xcworkspace', @@ -350,6 +354,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'ios/Runner.xcworkspace', @@ -366,6 +371,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'macos/Runner.xcworkspace', @@ -406,6 +412,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'macos/Runner.xcworkspace', @@ -445,6 +452,7 @@ void main() { 'xcrun', const [ 'xcodebuild', + 'clean', 'analyze', '-workspace', 'ios/Runner.xcworkspace', From 0f7a5ae3b1f1e758318684d9f645c3f10af77ba1 Mon Sep 17 00:00:00 2001 From: Victoria Ashworth Date: Mon, 3 Jun 2024 11:05:25 -0500 Subject: [PATCH 2/2] add comments to explain why cleaning --- script/tool/lib/src/native_test_command.dart | 2 ++ script/tool/lib/src/xcode_analyze_command.dart | 2 ++ 2 files changed, 4 insertions(+) diff --git a/script/tool/lib/src/native_test_command.dart b/script/tool/lib/src/native_test_command.dart index 8119e409c6c..20eef521de2 100644 --- a/script/tool/lib/src/native_test_command.dart +++ b/script/tool/lib/src/native_test_command.dart @@ -465,6 +465,8 @@ this command. _printRunningExampleTestsMessage(example, platform); final int exitCode = await _xcode.runXcodeBuild( example.directory, + // Clean before testing to remove cached swiftmodules from previous + // runs, which can cause conflicts. actions: ['clean', 'test'], workspace: '${platform.toLowerCase()}/Runner.xcworkspace', scheme: 'Runner', diff --git a/script/tool/lib/src/xcode_analyze_command.dart b/script/tool/lib/src/xcode_analyze_command.dart index 5795e439060..6760eeeff8e 100644 --- a/script/tool/lib/src/xcode_analyze_command.dart +++ b/script/tool/lib/src/xcode_analyze_command.dart @@ -111,6 +111,8 @@ class XcodeAnalyzeCommand extends PackageLoopingCommand { print('Running $platform tests and analyzer for $examplePath...'); final int exitCode = await _xcode.runXcodeBuild( example.directory, + // Clean before analyzing to remove cached swiftmodules from previous + // runs, which can cause conflicts. actions: ['clean', 'analyze'], workspace: '${platform.toLowerCase()}/Runner.xcworkspace', scheme: 'Runner',