Skip to content

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

Closed
flutter/packages
#7430

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

Activity

  1. added
    platform-iosiOS applications specifically
    packageflutter/packages repository. See also p: labels.
    P2Important issues not at the top of the work list
    team-iosOwned by iOS platform team
    triaged-iosTriaged by iOS platform team
    on Mar 7, 2024
  2. jmagman commented on Mar 7, 2024

    @jmagman
    MemberAuthor

    @stuartmorgan I thought we had an issue for this but I can't find it.

  3. hellohuanlin commented on Mar 8, 2024

    @hellohuanlin
    Contributor

    random thought - maybe we can share some common infra for these 2 repos?

  4. github-actions commented on Nov 20, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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