Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

Since we added warnings to the test clock I have been seeing some spurious warnings in our internal tests. It appears this is related to tests that that use the TestClock to do sleeping but complete without adjusting it (e.g. delaying an effect, forking it, then checking that it can be interrupted). To prevent this, this PR has making a TestClock return a Managed where the release action is canceling the warning.

@adamgfraser adamgfraser requested a review from jdegoes November 11, 2019 04:23
@adamgfraser
Copy link
Contributor Author

Thinking about this more I am not really happy with this change. It feels like we are leaking too many implementation details by having to change the signature of TestClock.make and introducing irregularity with the constructors for the other test implementations. It looks like a good amount of the issue is that sometimes an effect is put to sleep in an uninterruptible block which by default makes the warning fiber uninterruptible. That is a very easy fix that we can do purely internally. Then any other warnings would be cases where sleep was called but adjust or its equivalents was never called, in which case sleep could just be replaced by never so we don't need to change all of our signatures to support that. I will update shortly.

Copy link
Member

@jdegoes jdegoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better! ❤️

@jdegoes jdegoes merged commit 4f63e1d into zio:master Nov 11, 2019
@adamgfraser
Copy link
Contributor Author

@jdegoes Sorry I had some second thoughts about this that I was in the process of making.

The version we merged has creating a TestClock return a Managed, so advantage is that warning will get canceled if test completes even though sleep is used and clock is not adjusted. Disadvantage is that TestClock.make now returns a Managed unlike the constructors for all the other test implementations and is a little harder to use.

I was thinking of going with a more minimalistic change where we just made the warning fiber interruptible (it could be uninterruptible before if the clock adjustment occurred in an uninterruptible region). Disadvantage is warning could still be displayed if a test completed with a sleep and no adjustment, but in that case the sleep effect could just be replaced with never (though that could be harder if the sleep is composed into some larger effect you are calling).

I see the pluses and minuses of both and am happy either way, just want to make sure we are aligned.

@adamgfraser adamgfraser deleted the testclock branch November 12, 2019 05:20
Twizty pushed a commit to Twizty/zio that referenced this pull request Nov 13, 2019
* prevent spurious test clock warning

* make warning fiber interruptible
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.

2 participants