Skip to content

Fix bug that would cause scopes to be improperly reported in EasyTest #2008

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

Merged
merged 2 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions yaks/easytest/src/EasyTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ scope :: String -> Test a -> Test a
scope msg (Test t) = wrap . Test $ do
env <- ask
let messages' = case messages env of [] -> msg; ms -> ms ++ ('.':msg)
let env' = env {messages = messages', allow = drop (length msg + 1) (allow env)}
if null (allow env) || take (length (allow env)) msg `isPrefixOf` allow env
then liftIO $
runReaderT t (env {messages = messages', allow = drop (length msg + 1) (allow env)})
then liftIO (runWrap env' t)
else putResult Skipped >> pure Nothing

-- | Log a message
Expand Down Expand Up @@ -357,7 +357,7 @@ crash msg = do
nologging :: HasCallStack => Test a -> Test a
nologging (Test t) = Test $ do
env <- ask
liftIO $ runReaderT t (env {note_ = \_ -> pure ()})
liftIO $ runWrap (env {note_ = \_ -> pure ()}) t

-- | Run a test under a new scope, without logs and suppressing all output
attempt :: Test a -> Test (Maybe a)
Expand Down
5 changes: 4 additions & 1 deletion yaks/easytest/tests/Suite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ suite1 = tests
[ scope "a" ok
, scope "b.c" ok
, scope "b" ok
-- leaving this commented out until we have a function like:
-- `expectFailure :: Scope -> Test a -> Test a`
-- , scope "b" . scope "c" $ error "oh noes! - should fail with b.c scope"
, scope "b" . scope "c" . scope "d" $ ok
, scope "c" ok ]

suite2 :: Test ()
suite2 = tests
[ scope "pending.failure" (pending (expectEqual True False))
--, scope "pending.success" (pending ok)
--, scope "pending.success" (pending ok)
]

reverseTest :: Test ()
Expand Down