Skip to content

Refactor to undo the removal of the real Env from Spec.#26

Merged
jemc merged 1 commit intomainfrom
undo/fake-env
Sep 29, 2022
Merged

Refactor to undo the removal of the real Env from Spec.#26
jemc merged 1 commit intomainfrom
undo/fake-env

Conversation

@jemc
Copy link
Copy Markdown
Contributor

@jemc jemc commented Sep 28, 2022

Prior to #17, Spec.env would return a real instance of the Env, which the spec examples could use in any way (for example, using it as the root of authority to create a capability object such as with TCP.auth). But #17 removed this in favor of a Spec.Env abstraction that wraps a possible Env, but may not hold a real one.

This was done for the purpose of making it possible to test the effects of Spec.Process.run in Spec.Process.Spec, so that we could have tests in the Spec package that test itself.

However, it was not actually necessary to remove the real Env from Spec.env to accomplish this - we can still pass the user code the real Env, but use a capturing abstraction for spec effects (i.e. exit code and printed output).

This PR renames Spec.Env as _Effects, and brings back the real Env as being present at Spec.env, while the internal mechanisms that set the exit code and print results will use _Effects instead, such that these effects can still be captured and tested in our self-test.

See discussion in Zulip at:
https://savi.zulipchat.com/#narrow/stream/294906-libraries/topic/Spec/near/301273284

Prior to #17, `Spec.env` would return a real instance of the `Env`,
which the spec examples could use in any way (for example, using
it as the root of authority to create a capability object such
as with `TCP.auth`). But #17 removed this in favor of a `Spec.Env`
abstraction that wraps a possible `Env`, but may not hold a real one.

This was done for the purpose of making it possible to test the
effects of `Spec.Process.run` in `Spec.Process.Spec`, so that
we could have tests in the `Spec` package that test itself.

However, it was not actually necessary to remove the real `Env` from
`Spec.env` to accomplish this - we can still pass the user code
the real `Env`, but use a capturing abstraction for spec effects
(i.e. exit code and printed output).

This PR renames `Spec.Env` as `_Effects`, and brings back the real
`Env` as being present at `Spec.env`, while the internal mechanisms
that set the exit code and print results will use `_Effects` instead,
such that these effects can still be captured and tested in our
self-test.

See discussion in Zulip at:
https://savi.zulipchat.com/#narrow/stream/294906-libraries/topic/Spec/near/301273284
@jemc jemc self-assigned this Sep 28, 2022
@jemc jemc merged commit df78635 into main Sep 29, 2022
@jemc jemc deleted the undo/fake-env branch September 29, 2022 01:03
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

Successfully merging this pull request may close these issues.

1 participant