ZIO Test: Close Resources Earlier In ProvideLayerShared #3696
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Right now we are keeping resources open too long with
provideLayerShared. Basically we are building one giantZManagedfor all the suites and specs in a test and then running them so the result is we are closing all the shared resources at the end of the spec instead of at the end of the suite they are provided to. To address this I added areleasecombinator onZManagedthat conceptually "closes" the scope.This works but looking at this the
onlycombinator is quite problematic. It requires us to traverse the entire spec, which means acquiring all the resources in any nested suites, to determine whether there is any test annotated withonly. For example if a spec is to be run sequentially we need to acquire and release the resources for suites one by one but we also need to potentially examine all of the suites and acquire their resources to determine which ones we should run. I have removed it for now though it is a very nice combinator and I would like to figure out a way to support it.