Skip to content

Commit

Permalink
Rename the function to readFileVerbatim
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Dec 23, 2024
1 parent 13984b8 commit 667bb9c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ 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" ]

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

-- The project is named oops as it is like hops but has conflicting constraints.
Expand All @@ -129,7 +129,7 @@ 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" ]

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

-- The project is named yops as it is like hops but with y's for forks.
Expand Down Expand Up @@ -172,7 +172,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" ]

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

return ()
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ main = cabalTest . recordMode RecordMarked $ do
log "check project configuration with URI imports is listed in full and"
log "check package directories and locations are reported in order"

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

return ()
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ main = cabalTest . recordMode RecordMarked $ do

outElse <- fails $ cabal' "v2-build" [ "all", "--dry-run", "--project-file=else.project" ]

msg <- readVerbatimFile "msg.expect.txt"
msg <- readFileVerbatim "msg.expect.txt"
let msgSingle = lineBreaksToSpaces msg

log "Multiline string marking:"
Expand Down
4 changes: 2 additions & 2 deletions cabal-testsuite/src/Test/Cabal/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,8 +1292,8 @@ findDependencyInStore pkgName = do
-- > "\\\\?\\C:\\Users\\<username>\\AppData\\Local\\Temp\\cabal-testsuite-8376\\errors.expect.txt":
-- > permission denied (The process cannot access the file because it is being
-- > used by another process.)
readVerbatimFile :: FilePath -> TestM String
readVerbatimFile filename = do
readFileVerbatim :: FilePath -> TestM String
readFileVerbatim filename = do
testDir <- testCurrentDir <$> getTestEnv
s <- liftIO . readFile $ testDir </> filename
length s `seq` return s
2 changes: 1 addition & 1 deletion changelog.d/pr-10646.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ With `ghc-9.12.1` adding `-XMultilineStrings` it would be easier to write
multiline strings in `cabal-testsuite/PackageTests/**/*.test.hs` scripts but the
catch is we run these tests with older `GHC` versions so would need to use
`-XCPP` for those versions and the C preprocessor does not play nicely with
string gaps. To avoid these problems a `readVerbatimFile` function can be used
string gaps. To avoid these problems a `readFileVerbatim` function can be used
to read the expected multiline output for tests verbatim. This has the same
implementation as `readFile` from the `strict-io` package to avoid problems at
cleanup.
Expand Down

0 comments on commit 667bb9c

Please sign in to comment.