diff --git a/cabal-install/parser-tests/Tests/ParserTests.hs b/cabal-install/parser-tests/Tests/ParserTests.hs index 840b5ca0e06..de6d520574a 100644 --- a/cabal-install/parser-tests/Tests/ParserTests.hs +++ b/cabal-install/parser-tests/Tests/ParserTests.hs @@ -24,7 +24,7 @@ import Distribution.Client.Targets (readUserConstraint) import Distribution.Client.Types.AllowNewer (AllowNewer (..), AllowOlder (..), RelaxDepMod (..), RelaxDepScope (..), RelaxDepSubject (..), RelaxDeps (..), RelaxedDep (..)) import Distribution.Client.Types.InstallMethod (InstallMethod (..)) import Distribution.Client.Types.OverwritePolicy (OverwritePolicy (..)) -import Distribution.Client.Types.Repo (LocalRepo (..), RemoteRepo (..)) +import Distribution.Client.Types.Repo (LocalRepo (..), RemoteRepo (..), asPosixPath) import Distribution.Client.Types.RepoName (RepoName (..)) import Distribution.Client.Types.SourceRepo import Distribution.Client.Types.WriteGhcEnvironmentFilesPolicy (WriteGhcEnvironmentFilesPolicy (..)) @@ -48,6 +48,7 @@ import Distribution.Solver.Types.Settings , ReorderGoals (..) , StrongFlags (..) ) +import Distribution.System (OS (..), buildOS) import Distribution.Types.CondTree (CondTree (..)) import Distribution.Types.Flag (mkFlagAssignment) import Distribution.Types.PackageId (PackageIdentifier (..)) @@ -301,15 +302,18 @@ testLocalNoIndexRepos = do myRepository = LocalRepo { localRepoName = RepoName $ "my-repository" - , localRepoPath = "/absolute/path/to/directory" + , localRepoPath = normalisePath "/absolute/path/to/directory" , localRepoSharedCache = False } mySecureRepository = LocalRepo { localRepoName = RepoName $ "my-other-repository" - , localRepoPath = "/another/path/to/repository" + , localRepoPath = normalisePath "/another/path/to/repository" , localRepoSharedCache = False } + normalisePath path = case buildOS of + Windows -> asPosixPath path + _ -> path testProjectConfigProvenance :: Assertion testProjectConfigProvenance = do diff --git a/cabal-install/src/Distribution/Client/Types/Repo.hs b/cabal-install/src/Distribution/Client/Types/Repo.hs index 9cbe428bd77..d3caac872db 100644 --- a/cabal-install/src/Distribution/Client/Types/Repo.hs +++ b/cabal-install/src/Distribution/Client/Types/Repo.hs @@ -21,6 +21,7 @@ module Distribution.Client.Types.Repo , maybeRepoRemote -- * Windows + , asPosixPath , normaliseFileNoIndexURI ) where @@ -251,8 +252,10 @@ normaliseFileNoIndexURI os uri@(URI scheme _auth path query fragment) , Windows <- os = URI scheme Nothing (asPosixPath path) query fragment | otherwise = uri - where - asPosixPath p = - -- We don't use 'isPathSeparator' because @Windows.isPathSeparator - -- Posix.pathSeparator == True@. - [if x == Windows.pathSeparator then Posix.pathSeparator else x | x <- p] + +-- | Convert a path to POSIX-style. +asPosixPath :: FilePath -> FilePath +asPosixPath p = + -- We don't use 'isPathSeparator' because @Windows.isPathSeparator + -- Posix.pathSeparator == True@. + [if x == Windows.pathSeparator then Posix.pathSeparator else x | x <- p]