Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for async fixtures #430

Merged
merged 10 commits into from
Oct 16, 2021
Merged

Commits on Oct 10, 2021

  1. Add support for async fixtures

    Previously, it was not possible to create fixtures that loaded
    asynchronously. It was possible to work around this limitation on the
    JVM by awaiting on futures, but there was no workaround for Scala.js.
    This commit adds support to return futures (and anything that converts
    to futures) from the beforeAll/beforeEach/afterEach/afterAll methods.
    
    Supersedes scalameta#418. This commit is
    inspired by that PR but uses a different approach:
    
    - No new `AsyncFixture[T]` type. This simplies the logic in
      `MUnitRunner` and reduces the size of the MUnit public API.
      The downside is that we introduce a breaking change to the existing
      `Fixture[T]` API, which will require bumping the version to v1.0.0
      for the next release.
    - This approach supports any `Future`-like values by hooking into the
      default evaluation of test bodies via `munitValueTransforms`.
    
    Co-authored-by: Daniel Esik <[email protected]>
    olafurpg and danicheg committed Oct 10, 2021
    Configuration menu
    Copy the full SHA
    69175cb View commit details
    Browse the repository at this point in the history

Commits on Oct 11, 2021

  1. Make tests pass

    A bug in Scala 2.11/2.12 made `TimeoutSuite` fail with the new async
    fixtures. This commit changes how we implement `munitTimeout` to race
    two futures instead of calling `Await.result`.
    olafurpg committed Oct 11, 2021
    Configuration menu
    Copy the full SHA
    995c22b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a9c06df View commit details
    Browse the repository at this point in the history
  3. Cleanup code

    olafurpg committed Oct 11, 2021
    Configuration menu
    Copy the full SHA
    cfc64be View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8a123cd View commit details
    Browse the repository at this point in the history
  5. Remove infinite loop test for TimeoutSuite

    This test case was causing CI failures on Linux that I wasn't able to
    reproduce on my local MacBook.
    olafurpg committed Oct 11, 2021
    Configuration menu
    Copy the full SHA
    2598fa6 View commit details
    Browse the repository at this point in the history
  6. Add infinite loop test back with a new execution context

    Previously, the test suite was using a parasitic execution context.
    olafurpg committed Oct 11, 2021
    Configuration menu
    Copy the full SHA
    68f9e6c View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2021

  1. Introduce AnyFixture to preserve Unit result type on Fixture

    Previously, the `Fixture` lifecycle methods returned `Any`, which meant
    that auto-completions would insert `Any` in the result type when
    auto-generating implementation of a fixture. Now, the `Fixture[T]` class
    has `Unit` as result types for consistency with older versions of MUnit.
    Instead, we introduce `AnyFixture[T]` which only needs to be used when
    comibing a list of `Fixture[T]` and `FutureFixture[T]` (along with
        3rdparty fixture classes).
    olafurpg committed Oct 16, 2021
    Configuration menu
    Copy the full SHA
    fd0ec09 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1b3854e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9e081b3 View commit details
    Browse the repository at this point in the history