Skip to content

awaiting async let function from lazy initialized object doesn't execute concurrently in an XCTest test case #63353

@sja26

Description

@sja26

Description

Executing inside of an XCTest class' test case method, that calls await on multiple consecutive async lets of which the async function resides in a lazy initialized variable, doesn't go on to run each function concurrently. Instead, only the first async function is called, the next async function doesn't get called concurrently. Targeting macOS or iOS Simulator yields the same result.

Steps to reproduce

  1. Clone example repo containing Swift Package
  2. Change directory to SwiftStructuredConcurrencyLazyBug
  3. Run swift test

Expected behavior

Executing inside of an XCTest class' test case method, that calls await on multiple consecutive async lets of which the async function resides in a lazy initialized variable, should run each function concurrently.

Environment

  • swift-driver version: 1.62.15 Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)
    Target: x86_64-apple-macosx13.0
  • Xcode 14.2 Build version 14C18
  • Deployment target: macOS 13, iOS 16

Additional context

I can't reproduce this behaviour outside of an XCTest class. See Swift Playground SwiftStructuredConcurrencyLazy in example repo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    XCTestFlag: Involves XCTestasync & awaitFeature → concurrency: asynchronous function aka the async/await patternbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresswift 5.7

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions