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

Use an actual bracket to handle test setup/cleanup #126

Open
jy14898 opened this issue Nov 29, 2022 · 4 comments
Open

Use an actual bracket to handle test setup/cleanup #126

jy14898 opened this issue Nov 29, 2022 · 4 comments

Comments

@jy14898
Copy link

jy14898 commented Nov 29, 2022

At the moment, cleanup is handled by simply running the cleanup after the test sub-tree:

loop (mapWithIndex indexer xs) <* lift (cleanup unit)

This isn't great, as it doesn't get run in situations where the Aff was cancelled. We can fix this by using Aff's bracket.

IMO this would also lead to a simpler implementation of the afterAll beforeAll hook if a full bracket is encoded in the tree data type

@JordanMartinez
Copy link
Contributor

Mind exploring this idea in a PR?

@JordanMartinez
Copy link
Contributor

😅 Then again, I don't have write-access to this repo, so I couldn't merge such a PR anyway.

@jy14898
Copy link
Author

jy14898 commented Dec 3, 2022

Smallest change would be to do:

- loop (mapWithIndex indexer xs) <* lift (cleanup unit)
+ bracket
+   (pure unit)
+   cleanup
+   (const $ loop $ mapWithIndex indexer xs)

But that wouldn't include simplifying beforeAll. I had a proof of concept for work, but I don't think it's in any usable state now (and based off an old version of purescript-spec).

I may take a look again when I have time

@fsoikin
Copy link
Member

fsoikin commented Dec 3, 2022

I can merge a PR @JordanMartinez if one is presented.

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

3 participants