Skip to content

Tests: Improve tests to not rely on a .seconds(...) #8770

Open
@bkhouri

Description

@bkhouri

The some tests have the following expectation, or equivalent:

try #require(sync.wait(timeout: .now() + .seconds(2)) == .success)

This test is prone to flaky behaviour as the 2-second "timer" may or may not be sufficient.

We should update these affected tests to have a more deterministic assertion that does not rely on "timing" or any other behaviour that may cause a flaky tests.

Some suggestions:

  • Perhaps Removing the timeout value all-together altogether and specifying a test-level timeout
  • Getting away from that synchronous .wait call, and instead using something asynchronous

At the time of writing, the tests were:

  • BasicsTests.ConcurrencyHelpersTest/threadSafeArrayStore()
  • BasicsTests.ConcurrencyHelpersTest/threadSafeBox()
  • BasicsTests.ConcurrencyHelpersTest/threadSafeKeyValueStore()
  • CommandsTests.RunCommandTests/swiftRunSIGINT(buildSystem:)

Metadata

Metadata

Assignees

No one assigned

    Labels

    test suiteimprovements to SwiftPM test suite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions