Skip to content

Commit

Permalink
Add isInfixOf predicate to assertOn calls
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Jan 11, 2025
1 parent 9b7ecbd commit 5e476e8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
5 changes: 3 additions & 2 deletions cabal-testsuite/PackageTests/CheckSetup/setup.test.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Test.Cabal.Prelude
import Data.List (isInfixOf)

-- Test that setup shows all the 'autogen-modules' warnings.
main = cabalTest $ do
Expand All @@ -18,7 +19,7 @@ main = cabalTest $ do
let lineBreakBlind = needleHaystack{txHaystack = txFwdBwdId{txFwd = lineBreaksToSpaces}}

-- Asserts for the desired check messages after configure.
assertOn lineBreakBlind libError1 checkResult
assertOn lineBreakBlind libError2 checkResult
assertOn isInfixOf lineBreakBlind libError1 checkResult
assertOn isInfixOf lineBreakBlind libError2 checkResult

return ()
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Test.Cabal.Prelude
import Test.Cabal.OutputNormalizer
import Data.Function ((&))
import Data.Functor ((<&>))
import Data.List (isInfixOf)

main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
let log = recordHeader . pure
Expand Down Expand Up @@ -113,7 +114,7 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
hopping <- cabal' "v2-build" [ "--project-file=hops-0.project" ]

readFileVerbatim "hops.expect.txt" >>=
flip (assertOn multilineNeedleHaystack) hopping . normalizePathSeparators
flip (assertOn isInfixOf multilineNeedleHaystack) hopping . normalizePathSeparators

-- The project is named oops as it is like hops but has conflicting constraints.
-- +-- oops-0.project
Expand All @@ -130,7 +131,7 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
oopsing <- fails $ cabal' "v2-build" [ "all", "--project-file=oops-0.project" ]

readFileVerbatim "oops.expect.txt"
>>= flip (assertOn multilineNeedleHaystack) oopsing . normalizePathSeparators
>>= flip (assertOn isInfixOf multilineNeedleHaystack) oopsing . normalizePathSeparators

-- The project is named yops as it is like hops but with y's for forks.
-- +-- yops-0.project
Expand Down Expand Up @@ -173,6 +174,6 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do
missing <- fails $ cabal' "v2-build" [ "--project-file=cabal-missing-package.project" ]

readFileVerbatim "cabal-missing-package.expect.txt"
>>= flip (assertOn multilineNeedleHaystack) missing . normalizePathSeparators
>>= flip (assertOn isInfixOf multilineNeedleHaystack) missing . normalizePathSeparators

return ()
3 changes: 2 additions & 1 deletion cabal-testsuite/PackageTests/NewBuild/T4288/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Test.Cabal.Prelude
import Data.Function ((&))
import Data.List (isInfixOf)

-- This test is similar to the simplified example in issue #4288. The package's
-- setup script only depends on base and setup-helper. setup-helper exposes a
Expand All @@ -14,4 +15,4 @@ main = cabalTest $ do
"In order, the following will be built:\n\
\ - setup-helper-1.0 (lib:setup-helper) (first run)\n\
\ - T4288-1.0 (lib:T4288) (first run)"
& flip (assertOn multilineNeedleHaystack) r
& flip (assertOn isInfixOf multilineNeedleHaystack) r
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Test.Cabal.Prelude
import Data.Function ((&))
import Data.List (isInfixOf)

main = cabalTest . recordMode RecordMarked $ do
let log = recordHeader . pure
Expand All @@ -11,6 +12,6 @@ main = cabalTest . recordMode RecordMarked $ do
log "check package directories and locations are reported in order"

readFileVerbatim "errors.expect.txt"
>>= flip (assertOn multilineNeedleHaystack) out . normalizePathSeparators
>>= flip (assertOn isInfixOf multilineNeedleHaystack) out . normalizePathSeparators

return ()
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Test.Cabal.Prelude
import Data.Function ((&))
import Data.List (isInfixOf)

-- The local package, pkg-1.0, depends on build-tool-pkg-1 as a library and
-- build-tool-pkg-2 as a build-tool. This test checks that cabal uses the
Expand All @@ -22,8 +23,8 @@ main = cabalTest $ withShorterPathForNewBuildStore $ do
\ - build-tool-pkg-2 (lib) (requires build)\n\
\ - build-tool-pkg-2 (exe:build-tool-exe) (requires build)\n\
\ - pkg-1.0 (exe:my-exe) (first run)"
& flip (assertOn multilineNeedleHaystack) r1
& flip (assertOn isInfixOf multilineNeedleHaystack) r1

withPlan $ do
r2 <- runPlanExe' "pkg" "my-exe" []
assertOn multilineNeedleHaystack "build-tool library version: 1,\nbuild-tool exe version: 2" r2
assertOn isInfixOf multilineNeedleHaystack "build-tool library version: 1,\nbuild-tool exe version: 2" r2

0 comments on commit 5e476e8

Please sign in to comment.