From ff435b7fcaead3eea2456ce306ebdf290c3a9141 Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Sat, 11 Jan 2025 07:41:50 -0500 Subject: [PATCH] Add isInfixOf predicate to assertOn calls --- cabal-testsuite/PackageTests/CheckSetup/setup.test.hs | 5 +++-- .../PackageTests/ConditionalAndImport/cabal.test.hs | 7 ++++--- cabal-testsuite/PackageTests/NewBuild/T4288/cabal.test.hs | 3 ++- .../DedupUsingConfigFromComplex/cabal.test.hs | 3 ++- ...rsions-of-dependency-for-library-and-build-tool.test.hs | 5 +++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cabal-testsuite/PackageTests/CheckSetup/setup.test.hs b/cabal-testsuite/PackageTests/CheckSetup/setup.test.hs index 2a074db3c46..988faaabd8c 100644 --- a/cabal-testsuite/PackageTests/CheckSetup/setup.test.hs +++ b/cabal-testsuite/PackageTests/CheckSetup/setup.test.hs @@ -1,4 +1,5 @@ import Test.Cabal.Prelude +import Data.List (isInfixOf) -- Test that setup shows all the 'autogen-modules' warnings. main = cabalTest $ do @@ -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 () diff --git a/cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs b/cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs index 681865df2e5..5bcf8726850 100644 --- a/cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs +++ b/cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs @@ -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 @@ -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 @@ -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 @@ -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 () diff --git a/cabal-testsuite/PackageTests/NewBuild/T4288/cabal.test.hs b/cabal-testsuite/PackageTests/NewBuild/T4288/cabal.test.hs index 3313f596546..1e1fdc2e508 100644 --- a/cabal-testsuite/PackageTests/NewBuild/T4288/cabal.test.hs +++ b/cabal-testsuite/PackageTests/NewBuild/T4288/cabal.test.hs @@ -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 @@ -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 diff --git a/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cabal.test.hs b/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cabal.test.hs index e1419fb2467..50775e1133c 100644 --- a/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cabal.test.hs +++ b/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cabal.test.hs @@ -1,5 +1,6 @@ import Test.Cabal.Prelude import Data.Function ((&)) +import Data.List (isInfixOf) main = cabalTest . recordMode RecordMarked $ do let log = recordHeader . pure @@ -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 () diff --git a/cabal-testsuite/PackageTests/Regression/T5409/use-different-versions-of-dependency-for-library-and-build-tool.test.hs b/cabal-testsuite/PackageTests/Regression/T5409/use-different-versions-of-dependency-for-library-and-build-tool.test.hs index 4bbb8b91a9b..82246aaa4c0 100644 --- a/cabal-testsuite/PackageTests/Regression/T5409/use-different-versions-of-dependency-for-library-and-build-tool.test.hs +++ b/cabal-testsuite/PackageTests/Regression/T5409/use-different-versions-of-dependency-for-library-and-build-tool.test.hs @@ -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 @@ -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