From e36d9234e83ed9a6ab1619555ce8b0ac6be68f3a Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Fri, 26 Jul 2024 16:12:14 -0700 Subject: [PATCH] Change flutter_build_with_compilation_error_test to check stdout or stderr (#152404) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Xcode 16 beta 3 stderr is: ``` ** BUILD FAILED ** ``` stdout is: ``` Writing result bundle at path: /var/folders/fm/wjzsj_z95ydgn4khxqgbtqx000mfq2/T/flutter_tools.PeJZlH/flutter_ios_build_temp_dirqmiKld/temporary_xcresult_bundle error: lib/main.dart:13:11: Error: A value of type 'String' can't be assigned to a variable of type 'int'. int x = 'String'; ^ Target kernel_snapshot_program failed: Exception Failed to package /Users/m/Projects/test_create. note: Disabling previews because SWIFT_VERSION is set and SWIFT_OPTIMIZATION_LEVEL=-O, expected -Onone (in target 'Runner' from project 'Runner') note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner') note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner') ``` The tool output of `flutter build ios` shows both: ``` Building com.example.testCreate for device (ios-release)... Automatically signing iOS for device deployment using specified development team in Xcode project: S8QB4VV633 Running Xcode build... Xcode build done. 10.1s Failed to build iOS app Error output from Xcode build: ↳ ** BUILD FAILED ** Xcode's output: ↳ Writing result bundle at path: /var/folders/fm/wjzsj_z95ydgn4khxqgbtqx000mfq2/T/flutter_tools.Dgnlxc/flutt er_ios_build_temp_dirpKTDdk/temporary_xcresult_bundle error: lib/main.dart:13:11: Error: A value of type 'String' can't be assigned to a variable of type 'int'. int x = 'String'; ^ Target kernel_snapshot_program failed: Exception Failed to package /Users/magder/Projects/test_create. note: Disabling previews because SWIFT_VERSION is set and SWIFT_OPTIMIZATION_LEVEL=-O, expected -Onone (in target 'Runner' from project 'Runner') note: Run script build phase 'Run Script' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner') note: Run script build phase 'Thin Binary' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'Runner' from project 'Runner') Encountered error while building for device. ``` The point of this test is that you can see the error `int x = 'String';` error in the tool output. https://github.com/flutter/flutter/issues/72608#issuecomment-797473109 I think just updating the test to check stderr or stdout is sufficient without touching the tool behavior. Fixes https://github.com/flutter/flutter/issues/151553 --- ...lutter_build_with_compilation_error_test.dart | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/flutter_tools/test/integration.shard/flutter_build_with_compilation_error_test.dart b/packages/flutter_tools/test/integration.shard/flutter_build_with_compilation_error_test.dart index 36d15e9085..07de04c3c1 100644 --- a/packages/flutter_tools/test/integration.shard/flutter_build_with_compilation_error_test.dart +++ b/packages/flutter_tools/test/integration.shard/flutter_build_with_compilation_error_test.dart @@ -63,14 +63,16 @@ int x = 'String'; '--no-codesign', ], workingDirectory: projectRoot.path); - expect( - result, - const ProcessResultMatcher( - exitCode: 1, - stderrPattern: "A value of type 'String' can't be assigned to a variable of type 'int'.", - ), - ); + const String errorMessage = "A value of type 'String' can't be assigned to a variable of type 'int'."; + + // Xcode 16 moved the xcodebuild error details from stderr to stdout. + // Check that it's contained in one or the other. + final bool matchStdout = result.stdout.toString().contains(errorMessage); + final bool matchStderr = result.stderr.toString().contains(errorMessage); + + expect(matchStdout || matchStderr, isTrue); expect(result.stderr, isNot(contains("Warning: The 'dart2js' entrypoint script is deprecated"))); + expect(result.stdout, isNot(contains("Warning: The 'dart2js' entrypoint script is deprecated"))); }); } }