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

Shrinking with resources is broken #531

Open
NorfairKing opened this issue May 21, 2021 · 0 comments
Open

Shrinking with resources is broken #531

NorfairKing opened this issue May 21, 2021 · 0 comments
Labels

Comments

@NorfairKing
Copy link

NorfairKing commented May 21, 2021

This Spec shows "Invariant of resources not maintained during shrinking" after 21 tests and 1 shrinks:

  modifyMaxSize (const 30) $
    describe "Shrinking" $ do
      var <- liftIO $ newTVarIO False
      let withTrue func = do
            atomically $ writeTVar var True
            r <- func
            atomically $ writeTVar var False
            pure r
      around_ withTrue $
        it "maintains resource invariants correctly" $
          forAllShrink (sized $ \n -> pure n) shrink $ \i -> do
            b <- readTVarIO var
            if b
              then i `shouldSatisfy` (< 20)
              else expectationFailure "Invariant of resources not maintained during shrinking"

As a result, debugging is broken when using around or before together with shrinking. The only way to find the real problem in that case is to turn off shrinking.)

I'm trying to fix this problem in sydtest at the moment but hspec has the same issue so I figured I'd report it so that it can be fixed in hspec as well.

@NorfairKing NorfairKing changed the title Shrinking with resources is bugged Shrinking with resources is broken May 21, 2021
@sol sol added the bug label Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants