Skip to content

Commit

Permalink
Don't modify path separator for URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
philderbeast committed Dec 21, 2024
1 parent d3c562f commit e104b8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions cabal-testsuite/cabal-testsuite.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ library
, exceptions ^>= 0.10.0
, filepath ^>= 1.3.0.1 || ^>= 1.4.0.0 || ^>= 1.5.0.0
, Glob ^>= 0.10.2
, network-uri >= 2.6.0.2 && < 2.7
, network-wait ^>= 0.1.2.0 || ^>= 0.2.0.0
, optparse-applicative ^>= 0.14.3.0 || ^>=0.15.1.0 || ^>=0.16.0.0 || ^>= 0.17.0.0 || ^>= 0.18.1.0
, process ^>= 1.2.1.0 || ^>= 1.4.2.0 || ^>= 1.6.1.0
Expand Down
13 changes: 10 additions & 3 deletions cabal-testsuite/src/Test/Cabal/NeedleHaystack.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{-# LANGUAGE MultiWayIf #-}

module Test.Cabal.NeedleHaystack where

import Data.Maybe (isJust)
import Distribution.System
import Data.List (isPrefixOf)
import qualified System.FilePath.Posix as Posix
import qualified System.FilePath.Windows as Windows
import Network.URI (parseURI)

-- | Transformations for the search strings and the text to search in.
data TxContains =
Expand Down Expand Up @@ -58,12 +62,15 @@ lineBreaksToSpaces = unwords . lines . filter ((/=) '\r')

normalizePathSeparator :: FilePath -> FilePath
normalizePathSeparator p =
if buildOS == Windows
then
if | isURI p -> p
| buildOS == Windows ->
[if Posix.isPathSeparator c then Windows.pathSeparator else c| c <- p]
else
| otherwise ->
[if Windows.isPathSeparator c then Posix.pathSeparator else c| c <- p]

isURI :: FilePath -> Bool
isURI = isJust . parseURI

normalizeWindowsOutput :: String -> String
normalizeWindowsOutput = unlines . map normalizePathSeparator . lines

Expand Down

0 comments on commit e104b8e

Please sign in to comment.