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

Expose waitForCompletion for overriding #570

Closed
armanbilge opened this issue Aug 22, 2022 · 1 comment
Closed

Expose waitForCompletion for overriding #570

armanbilge opened this issue Aug 22, 2022 · 1 comment

Comments

@armanbilge
Copy link
Contributor

This is used to support timeouts for tests.

def munitTimeout: Duration = new FiniteDuration(30, TimeUnit.SECONDS)
private final def waitForCompletion[T](f: () => Future[T]) =
PlatformCompat.waitAtMost(f, munitTimeout, munitExecutionContext)

The Scala Native implementation doesn't support timeouts (due to limitations of the single-threaded runtime). And actually I suspect the JavaScript one is broken too with the default parasitic execution context.

def waitAtMost[T](
startFuture: () => Future[T],
duration: Duration,
ec: ExecutionContext
): Future[T] = {
startFuture()
}

However, it is possible to implement timeouts for Scala Native when also overriding the ExecutionContext with a more sophisticated runtime.

For example the QueueExecutorScheduler in Cats Effect Native supports timeouts. Since we are using the Cats Effect runtime in munit-cats-effect, I would like to be able to support test timeouts there by overriding waitForCompletion.

Of course we could solve this in userland by adding timeouts to the IO-transform in munit-cats-effect, but then it wouldn't work for non-IO-based tests that also happen to be running in a Cats Effect suite.

@armanbilge
Copy link
Contributor Author

I decided to solve this in user-land. MUnit timeouts have other caveats, like lack of support for cancellation.

@armanbilge armanbilge closed this as not planned Won't fix, can't repro, duplicate, stale Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant