Skip to content

Commit

Permalink
Fix testLocalNoIndexRepos on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jgotoh committed Jan 27, 2025
1 parent 9ef429f commit 3252e2a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
10 changes: 7 additions & 3 deletions cabal-install/parser-tests/Tests/ParserTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (..))
Expand All @@ -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 (..))
Expand Down Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions cabal-install/src/Distribution/Client/Types/Repo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Distribution.Client.Types.Repo
, maybeRepoRemote

-- * Windows
, asPosixPath
, normaliseFileNoIndexURI
) where

Expand Down Expand Up @@ -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]

0 comments on commit 3252e2a

Please sign in to comment.