Skip to content

Scope withKnownIssue(isIntermittent:) gates in withTimeout tests to platforms that actually flake #334

@leogdion

Description

@leogdion

Context

Two test files use withKnownIssue(isIntermittent: true) to absorb timing-sensitive failures in the withTimeout / withTimeoutAndSignals helpers:

The failure mode is real but platform-bounded: simulator cooperative executors (observed on visionOS, watchOS, and previously wasm32) can starve the polling timeout task's many short Task.sleeps behind the operation task's single long Task.sleep, so the timeout helper returns the value instead of throwing AsyncTimeoutError.

Problem

A blanket withKnownIssue(isIntermittent: true) accepts the failure on every platform. That masks a real regression if the same test starts flaking on a platform where the timeout helper is supposed to be reliable — macOS host, Linux, iOS device, etc.

wasm32 already gets narrower treatment via .enabled(if: !TestPlatform.isWasm32, ...). The other simulator-cooperative-executor platforms are caught only by the broad intermittent gate.

What we want

Scope the intermittent allowance to the platforms that actually flake. Two reasonable shapes:

  • Conditional withKnownIssue: only wrap when on the flaky platform; assert strictly elsewhere.
    if TestPlatform.isFlakyTimeoutSimulator {
      await withKnownIssue(isIntermittent: true) { ... }
    } else {
      try await ...
      #expect(...)
    }
  • .disabled(if:) for the known-broken set: skip the test on platforms where the helper is unreliable, run it strictly elsewhere. Pairs naturally with the existing TestPlatform.isWasm32 pattern.

Either way: introduce a TestPlatform.isFlakyTimeoutSimulator (or similarly named) helper alongside isWasm32 so call sites stay declarative.

Affected sites

Out of scope

Fixing the underlying scheduling behavior of withTimeout on cooperative-executor platforms. That's a deeper concurrency-runtime topic; this issue is purely about scoping the test gates so a regression on a non-flaky platform fails loudly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions