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 asynchronous test fulfillment to spec package. #5

Closed
jemc opened this issue Jul 8, 2021 · 0 comments · Fixed by #12
Closed

Add asynchronous test fulfillment to spec package. #5

jemc opened this issue Jul 8, 2021 · 0 comments · Fixed by #12

Comments

@jemc
Copy link
Contributor

jemc commented Jul 8, 2021

Currently, our spec package has no facility for asynchronous test completion, and consequently our net package tests do not actually have any test assertions in them.

We want to add features similar to those that exist in Pony's ponytest (though as with everything else in Mare, if we have a better design we can come up with, we shouldn't let the Pony implementation be a constraint).

Specifically I am thinking about the expect_action/complete_action/fail_action features I added a while back to ponytest, which allow setting up named sub-completions within the test, then the overall test is counted as done when all named sub-completions have finished: https://github.com/ponylang/ponyc/blob/de8c1ab3488898facf66904f18219d1fd623c7c6/packages/ponytest/test_helper.pony#L398-L436

The scope of this ticket is to add something to Mare's spec package which serves a similar purpose, and demonstrate it by using it in the tests for the net package.

@jemc jemc transferred this issue from savi-lang/savi Mar 5, 2022
jemc added a commit that referenced this issue Mar 24, 2022
Resolves #5.

Now, if you need to test that something asynchronous happens,
you can call `@ctx.wait_for_action("my action")` to let the test
runner know that the test isn't over until the action completes.

After the asynchronous action is finished, you can mark it as such
by calling `@ctx.finished_action("my action")` to let the test
runner know that the action is complete.

You can add new actions to wait for at any time during a test,
but the names must be unique in order for them to be differentiated.

Once all awaited actions are marked as finished, the asynchronous
test example is done running.

If one or more actions don't get marked as finished in a timely manner,
an informational message will be printed every 5 seconds for all open
actions that are still being awaited.

If the whole test suite will time out after 30 seconds.

These time intervals will be able to be configured at runtime
using the constant override mechanism mentioned in this ticket:
savi-lang/savi#161
@jemc jemc closed this as completed in #12 Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant