From 907916b92b644213823e9953a264e0d20dd54e34 Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Wed, 1 Jan 2025 08:03:21 -0500 Subject: [PATCH] Add verbatim *.expect.txt expectations - Add oops.expect.txt - Add cabal-missing-package.expect.txt - Add hops.expect.txt - Add DedupUsingConfigFromComplex/errors.expect.txt - Add using configuration from to errors.expect.txt (cherry picked from commit 32b820bbb3dd884b551a5d56229b341cde55d9d0) --- .../cabal-missing-package.expect.txt | 6 ++ .../ConditionalAndImport/cabal.test.hs | 93 ++----------------- .../ConditionalAndImport/hops.expect.txt | 56 +++++++++++ .../ConditionalAndImport/oops.expect.txt | 16 ++++ .../DedupUsingConfigFromComplex/cabal.test.hs | 37 +------- .../errors.expect.txt | 19 ++++ 6 files changed, 110 insertions(+), 117 deletions(-) create mode 100644 cabal-testsuite/PackageTests/ConditionalAndImport/cabal-missing-package.expect.txt create mode 100644 cabal-testsuite/PackageTests/ConditionalAndImport/hops.expect.txt create mode 100644 cabal-testsuite/PackageTests/ConditionalAndImport/oops.expect.txt create mode 100644 cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/errors.expect.txt diff --git a/cabal-testsuite/PackageTests/ConditionalAndImport/cabal-missing-package.expect.txt b/cabal-testsuite/PackageTests/ConditionalAndImport/cabal-missing-package.expect.txt new file mode 100644 index 00000000000..f81a82a6c73 --- /dev/null +++ b/cabal-testsuite/PackageTests/ConditionalAndImport/cabal-missing-package.expect.txt @@ -0,0 +1,6 @@ +When using configuration from: + - cabal-missing-package.project + - missing/pkgs.config + - missing/pkgs/default.config +The following errors occurred: + - The package location 'pkg-doesnt-exist' does not exist. diff --git a/cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs b/cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs index c3f4b71baed..8b2aa5e5292 100644 --- a/cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs +++ b/cabal-testsuite/PackageTests/ConditionalAndImport/cabal.test.hs @@ -1,6 +1,7 @@ import Test.Cabal.Prelude import Test.Cabal.OutputNormalizer import Data.Function ((&)) +import Data.Functor ((<&>)) main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do let log = recordHeader . pure @@ -78,7 +79,7 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do -- +-- etc log "checking that cyclical check catches a same file name that imports itself" cyclical4a <- fails $ cabal' "v2-build" [ "--project-file=cyclical-same-filename-out-out-self.project" ] - assertOutputContains (normalizeWindowsOutput "cyclical import of same-filename/cyclical-same-filename-out-out-self.config") cyclical4a + assertOutputContains (normalizePathSeparators "cyclical import of same-filename/cyclical-same-filename-out-out-self.config") cyclical4a -- +-- cyclical-same-filename-out-out-backback.project -- +-- cyclical-same-filename-out-out-backback.config @@ -111,64 +112,8 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do log "checking that imports work skipping into a subfolder and then back out again and again" hopping <- cabal' "v2-build" [ "--project-file=hops-0.project" ] - "Configuration is affected by the following files:\n\ - \- hops-0.project\n\ - \- hops-2.config\n\ - \ imported by: hops/hops-1.config\n\ - \ imported by: hops-0.project\n\ - \- hops-4.config\n\ - \ imported by: hops/hops-3.config\n\ - \ imported by: hops-2.config\n\ - \ imported by: hops/hops-1.config\n\ - \ imported by: hops-0.project\n\ - \- hops-6.config\n\ - \ imported by: hops/hops-5.config\n\ - \ imported by: hops-4.config\n\ - \ imported by: hops/hops-3.config\n\ - \ imported by: hops-2.config\n\ - \ imported by: hops/hops-1.config\n\ - \ imported by: hops-0.project\n\ - \- hops-8.config\n\ - \ imported by: hops/hops-7.config\n\ - \ imported by: hops-6.config\n\ - \ imported by: hops/hops-5.config\n\ - \ imported by: hops-4.config\n\ - \ imported by: hops/hops-3.config\n\ - \ imported by: hops-2.config\n\ - \ imported by: hops/hops-1.config\n\ - \ imported by: hops-0.project\n\ - \- hops/hops-1.config\n\ - \ imported by: hops-0.project\n\ - \- hops/hops-3.config\n\ - \ imported by: hops-2.config\n\ - \ imported by: hops/hops-1.config\n\ - \ imported by: hops-0.project\n\ - \- hops/hops-5.config\n\ - \ imported by: hops-4.config\n\ - \ imported by: hops/hops-3.config\n\ - \ imported by: hops-2.config\n\ - \ imported by: hops/hops-1.config\n\ - \ imported by: hops-0.project\n\ - \- hops/hops-7.config\n\ - \ imported by: hops-6.config\n\ - \ imported by: hops/hops-5.config\n\ - \ imported by: hops-4.config\n\ - \ imported by: hops/hops-3.config\n\ - \ imported by: hops-2.config\n\ - \ imported by: hops/hops-1.config\n\ - \ imported by: hops-0.project\n\ - \- hops/hops-9.config\n\ - \ imported by: hops-8.config\n\ - \ imported by: hops/hops-7.config\n\ - \ imported by: hops-6.config\n\ - \ imported by: hops/hops-5.config\n\ - \ imported by: hops-4.config\n\ - \ imported by: hops/hops-3.config\n\ - \ imported by: hops-2.config\n\ - \ imported by: hops/hops-1.config\n\ - \ imported by: hops-0.project" - & normalizeWindowsOutput - & flip (assertOn multilineNeedleHaystack) hopping + readFileVerbatim "hops.expect.txt" >>= + flip (assertOn multilineNeedleHaystack) hopping . normalizePathSeparators -- The project is named oops as it is like hops but has conflicting constraints. -- +-- oops-0.project @@ -184,24 +129,8 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do log "checking conflicting constraints skipping into a subfolder and then back out again and again" oopsing <- fails $ cabal' "v2-build" [ "all", "--project-file=oops-0.project" ] - "Could not resolve dependencies:\n\ - \[__0] trying: oops-0.1 (user goal)\n\ - \[__1] next goal: hashable (dependency of oops)\n\ - \[__1] rejecting: hashable-1.4.3.0\n\ - \ (constraint from oops/oops-9.config requires ==1.4.2.0)\n\ - \ imported by: oops-8.config\n\ - \ imported by: oops/oops-7.config\n\ - \ imported by: oops-6.config\n\ - \ imported by: oops/oops-5.config\n\ - \ imported by: oops-4.config\n\ - \ imported by: oops/oops-3.config\n\ - \ imported by: oops-2.config\n\ - \ imported by: oops/oops-1.config\n\ - \ imported by: oops-0.project\n\ - \[__1] rejecting: hashable-1.4.2.0\n\ - \ (constraint from oops-0.project requires ==1.4.3.0)" - & normalizeWindowsOutput - & flip (assertOn multilineNeedleHaystack) oopsing + readFileVerbatim "oops.expect.txt" + >>= flip (assertOn multilineNeedleHaystack) oopsing . normalizePathSeparators log "checking bad conditional" badIf <- fails $ cabal' "v2-build" [ "--project-file=bad-conditional.project" ] @@ -210,13 +139,7 @@ main = cabalTest . withRepo "repo" . recordMode RecordMarked $ do log "checking that missing package message lists configuration provenance" missing <- fails $ cabal' "v2-build" [ "--project-file=cabal-missing-package.project" ] - "When using configuration from:\n\ - \ - cabal-missing-package.project\n\ - \ - missing/pkgs.config\n\ - \ - missing/pkgs/default.config\n\ - \The following errors occurred:\n\ - \ - The package location 'pkg-doesnt-exist' does not exist." - & normalizeWindowsOutput - & flip (assertOn multilineNeedleHaystack) missing + readFileVerbatim "cabal-missing-package.expect.txt" + >>= flip (assertOn multilineNeedleHaystack) missing . normalizePathSeparators return () diff --git a/cabal-testsuite/PackageTests/ConditionalAndImport/hops.expect.txt b/cabal-testsuite/PackageTests/ConditionalAndImport/hops.expect.txt new file mode 100644 index 00000000000..bf3ea9bc001 --- /dev/null +++ b/cabal-testsuite/PackageTests/ConditionalAndImport/hops.expect.txt @@ -0,0 +1,56 @@ +Configuration is affected by the following files: +- hops-0.project +- hops-2.config + imported by: hops/hops-1.config + imported by: hops-0.project +- hops-4.config + imported by: hops/hops-3.config + imported by: hops-2.config + imported by: hops/hops-1.config + imported by: hops-0.project +- hops-6.config + imported by: hops/hops-5.config + imported by: hops-4.config + imported by: hops/hops-3.config + imported by: hops-2.config + imported by: hops/hops-1.config + imported by: hops-0.project +- hops-8.config + imported by: hops/hops-7.config + imported by: hops-6.config + imported by: hops/hops-5.config + imported by: hops-4.config + imported by: hops/hops-3.config + imported by: hops-2.config + imported by: hops/hops-1.config + imported by: hops-0.project +- hops/hops-1.config + imported by: hops-0.project +- hops/hops-3.config + imported by: hops-2.config + imported by: hops/hops-1.config + imported by: hops-0.project +- hops/hops-5.config + imported by: hops-4.config + imported by: hops/hops-3.config + imported by: hops-2.config + imported by: hops/hops-1.config + imported by: hops-0.project +- hops/hops-7.config + imported by: hops-6.config + imported by: hops/hops-5.config + imported by: hops-4.config + imported by: hops/hops-3.config + imported by: hops-2.config + imported by: hops/hops-1.config + imported by: hops-0.project +- hops/hops-9.config + imported by: hops-8.config + imported by: hops/hops-7.config + imported by: hops-6.config + imported by: hops/hops-5.config + imported by: hops-4.config + imported by: hops/hops-3.config + imported by: hops-2.config + imported by: hops/hops-1.config + imported by: hops-0.project diff --git a/cabal-testsuite/PackageTests/ConditionalAndImport/oops.expect.txt b/cabal-testsuite/PackageTests/ConditionalAndImport/oops.expect.txt new file mode 100644 index 00000000000..88c23627575 --- /dev/null +++ b/cabal-testsuite/PackageTests/ConditionalAndImport/oops.expect.txt @@ -0,0 +1,16 @@ +Could not resolve dependencies: +[__0] trying: oops-0.1 (user goal) +[__1] next goal: hashable (dependency of oops) +[__1] rejecting: hashable-1.4.3.0 + (constraint from oops/oops-9.config requires ==1.4.2.0) + imported by: oops-8.config + imported by: oops/oops-7.config + imported by: oops-6.config + imported by: oops/oops-5.config + imported by: oops-4.config + imported by: oops/oops-3.config + imported by: oops-2.config + imported by: oops/oops-1.config + imported by: oops-0.project +[__1] rejecting: hashable-1.4.2.0 + (constraint from oops-0.project requires ==1.4.3.0) diff --git a/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cabal.test.hs b/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cabal.test.hs index 0c65ff68c60..e1419fb2467 100644 --- a/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cabal.test.hs +++ b/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/cabal.test.hs @@ -4,40 +4,13 @@ import Data.Function ((&)) main = cabalTest . recordMode RecordMarked $ do let log = recordHeader . pure - log "checking \"using config from message\" with URI imports" + log "check \"using config from message\" with URI imports" out <- fails $ cabal' "v2-build" [ "all", "--dry-run", "--project-file=no-pkgs.project" ] - -- Use assertRegex when the output is tainted by the temp directory, like - -- this: - -- - -- When using configuration from: - -- - /tmp/cabal-testsuite-282695/cabal.project - -- - /tmp/cabal-testsuite-282695/2.config etc - assertRegex - "Project configuration with URI imports is listed in full" - "When using configuration from:(\n|\r\n) \ - \ .*no-pkgs\\.project(\n|\r\n) \ - \ .*0\\.config(\n|\r\n) \ - \ .*2\\.config(\n|\r\n) \ - \ .*4\\.config(\n|\r\n) \ - \ .*6\\.config(\n|\r\n) \ - \ .*8\\.config(\n|\r\n) \ - \ .*1\\.config(\n|\r\n) \ - \ .*3\\.config(\n|\r\n) \ - \ .*5\\.config(\n|\r\n) \ - \ .*7\\.config(\n|\r\n) \ - \ .*9\\.config(\n|\r\n) \ - \ .*with-ghc\\.config(\n|\r\n) \ - \ .*https://www.stackage.org/lts-21.25/cabal.config(\n|\r\n)" - out + log "check project configuration with URI imports is listed in full and" + log "check package directories and locations are reported in order" - log "checking that package directories and locations are reported in order" - - "The following errors occurred:\n\ - \ - The package directory 'no-pkg-1' does not contain any .cabal file.\n\ - \ - The package location 'no-pkg-2-dir' does not exist.\n\ - \ - The package directory 'no-pkg-3' does not contain any .cabal file.\n\ - \ - The package location 'no-pkg-4-dir' does not exist." - & flip (assertOn multilineNeedleHaystack) out + readFileVerbatim "errors.expect.txt" + >>= flip (assertOn multilineNeedleHaystack) out . normalizePathSeparators return () diff --git a/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/errors.expect.txt b/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/errors.expect.txt new file mode 100644 index 00000000000..93907eea807 --- /dev/null +++ b/cabal-testsuite/PackageTests/ProjectImport/DedupUsingConfigFromComplex/errors.expect.txt @@ -0,0 +1,19 @@ +When using configuration from: + - no-pkgs.project + - 0.config + - 2.config + - 4.config + - 6.config + - 8.config + - cfg/1.config + - cfg/3.config + - cfg/5.config + - cfg/7.config + - cfg/9.config + - with-ghc.config + - https://www.stackage.org/lts-21.25/cabal.config +The following errors occurred: + - The package directory 'no-pkg-1' does not contain any .cabal file. + - The package location 'no-pkg-2-dir' does not exist. + - The package directory 'no-pkg-3' does not contain any .cabal file. + - The package location 'no-pkg-4-dir' does not exist.