From ae7ff21e5e428fc6508ceed39e5f228468dee742 Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Sat, 21 Dec 2024 08:31:50 -0500 Subject: [PATCH] Easier diff when assertOn follows assertOutputContains --- cabal-testsuite/src/Test/Cabal/Prelude.hs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/cabal-testsuite/src/Test/Cabal/Prelude.hs b/cabal-testsuite/src/Test/Cabal/Prelude.hs index 31d4f3c758b..1bbdebbec25 100644 --- a/cabal-testsuite/src/Test/Cabal/Prelude.hs +++ b/cabal-testsuite/src/Test/Cabal/Prelude.hs @@ -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 $ @@ -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 $