-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to test asynchronous actions.
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
- Loading branch information
Showing
10 changed files
with
291 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
:trait box Spec.Context.Holder | ||
:fun ctx Spec.Context | ||
|
||
:class val Spec.Context | ||
:let env Env | ||
:let process Spec.Process | ||
:let spec String | ||
:let example String | ||
:new (@env, @process, @spec, @example) | ||
:let _process Spec.Process | ||
:let _runner _Runner.Any | ||
:new (@env, @spec, @example, @_process, @_runner) | ||
|
||
:trait box Spec.Context.Holder | ||
:fun ctx Spec.Context | ||
:fun wait_for_action( | ||
action String | ||
pos = source_code_position_of_argument action | ||
) | ||
@_process.enqueue( | ||
Spec.Assert.WaitForAction.new(@spec, @example, action, pos) | ||
) | ||
|
||
:fun finished_action( | ||
action String | ||
pos = source_code_position_of_argument action | ||
) | ||
@_process.enqueue( | ||
Spec.Assert.FinishedAction.new(@spec, @example, action, pos) | ||
) | ||
|
||
:fun dispose_when_done(actor) | ||
@_runner.dispose_when_done(actor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.