Skip to content

Commit

Permalink
Easier diff when assertOn follows assertOutputContains
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Dec 21, 2024
1 parent b477512 commit ae7ff21
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions cabal-testsuite/src/Test/Cabal/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,18 @@ recordMode mode = withReaderT (\env -> env {
testRecordUserMode = Just mode
})

assertOutputContains :: MonadIO m => WithCallStack (String -> Result -> m ())
assertOutputContains = assertOn
needleHaystack
{txHaystack = TxContains{txBwd = decodeLfMarkLines, txFwd = encodeLf}}

assertOutputDoesNotContain :: MonadIO m => WithCallStack (String -> Result -> m ())
assertOutputDoesNotContain = assertOn
needleHaystack
{ expectNeedleInHaystack = False
, txHaystack = TxContains{txBwd = decodeLfMarkLines, txFwd = encodeLf}
}

assertOn :: MonadIO m => WithCallStack (NeedleHaystack -> String -> Result -> m ())
assertOn NeedleHaystack{..} (txFwd txNeedle -> needle) (txFwd txHaystack. resultOutput -> output) =
withFrozenCallStack $
Expand All @@ -814,16 +826,6 @@ assertOn NeedleHaystack{..} (txFwd txNeedle -> needle) (txFwd txHaystack. result
then "\nin output:\n" ++ (txBwd txHaystack output)
else ""

assertOutputContains :: MonadIO m => WithCallStack (String -> Result -> m ())
assertOutputContains = assertOn needleHaystack{txHaystack = TxContains{txBwd = decodeLfMarkLines, txFwd = encodeLf}}

assertOutputDoesNotContain :: MonadIO m => WithCallStack (String -> Result -> m ())
assertOutputDoesNotContain = assertOn
needleHaystack
{ expectNeedleInHaystack = False
, txHaystack = TxContains{txBwd = decodeLfMarkLines, txFwd = encodeLf}
}

assertFindInFile :: MonadIO m => WithCallStack (String -> FilePath -> m ())
assertFindInFile needle path =
withFrozenCallStack $
Expand Down

0 comments on commit ae7ff21

Please sign in to comment.