Change flutter_build_with_compilation_error_test to check stdout or stderr (#152404)

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
This commit is contained in:
Jenn Magder 2024-07-26 16:12:14 -07:00 committed by GitHub
parent 058a45da1f
commit e36d9234e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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")));
});
}
}