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

Context and running streaks in parallel. #56

Open
pygy opened this issue Feb 7, 2023 · 0 comments
Open

Context and running streaks in parallel. #56

pygy opened this issue Feb 7, 2023 · 0 comments

Comments

@pygy
Copy link
Member

pygy commented Feb 7, 2023

This isn't a concern as far as Mithril or ospec itself are concerned, but a test suite that make async requests may see its run time dominated by network and remote work latency. In these scenarios, it could make sense to have streaks (a task and its corresponding beforeEach and afterEach hooks) run in parallel.

In that scenario, having them all share a context object would make a lot of sense.

The v5 API has a nice affordance for this with the injected o object.

We could have o("some test", (o, {spy, context, timeout} = o) => {...}) or even o("", ({o, spy, context, timeout}) => {...}) (if o.o ===o).

context could prototypically inherit from the spec context passed to before and after hooks (each spec having its own context that inherits from parent specs).

A context object is necessary in parallel mode because we can't rely on the closure variables not to be clobbered by other streaks running in parallel.

We could use o.parallel(maxParallelism?, callback), or overload o.spec(name, options = {parallel: false|number}, callback).

The latter is probably preferable.

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