Skip to content

Upload packages iOS native test xcresult bundle on test failure #144795

@jmagman

Description

@jmagman

On native iOS Xcode build test failures upload the xcresult bundle to the logs location so we can open it in Xcode and see the screenshots, etc. This is possible as of #121535.

This is where it would be updated:
https://github.com/flutter/packages/blob/903f03add169c39d3f19bc70980af3f0862869a9/script/tool/lib/src/common/xcode.dart#L34-L56

Here is how it's done in the framework repo:

final String resultBundleTemp = Directory.systemTemp.createTempSync('flutter_xcresult.').path;
final String resultBundlePath = path.join(resultBundleTemp, 'result');
final int testResultExit = await exec(
'xcodebuild',
<String>[
'-workspace',
'Runner.xcworkspace',
'-scheme',
'Runner',
'-configuration',
configuration,
'-destination',
destination,
'-resultBundlePath',
resultBundlePath,
'test',
'COMPILER_INDEX_STORE_ENABLE=NO',
if (developmentTeam != null)
'DEVELOPMENT_TEAM=$developmentTeam',
if (codeSignStyle != null)
'CODE_SIGN_STYLE=$codeSignStyle',
if (provisioningProfile != null)
'PROVISIONING_PROFILE_SPECIFIER=$provisioningProfile',
],
workingDirectory: platformDirectory,
canFail: true,

if (xcresultBundle.existsSync()) {
// Zip the test results to the artifacts directory for upload.
final String zipPath = path.join(dumpDirectory.path,
'$testName-${DateTime.now().toLocal().toIso8601String()}.zip');
await exec(
'zip',
<String>[
'-r',
'-9',
'-q',
zipPath,
path.basename(xcresultBundle.path),
],
workingDirectory: resultBundleTemp,
canFail: true, // Best effort to get the logs.
);

where dumpDirectory is platform.environment['FLUTTER_LOGS_DIR']

final String? directoryPath = _platform.environment['FLUTTER_LOGS_DIR'];
if (directoryPath != null) {
_dumpDirectory = _fileSystem.directory(directoryPath)..createSync(recursive: true);

This would particularly be helpful when tests are run in parallel because evidently it doesn't show the failures in stdout:
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8754096679487031185/+/u/Run_package_tests/native_test/stdout

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions