Commit 72b93d91 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Quote package locations with spaces when printing

And extend the project config print/parse tests to cover quoted strings.
parent f6c1e71c
......@@ -17,6 +17,7 @@ module Distribution.Client.ProjectConfig.Legacy (
-- * Internals, just for tests
parsePackageLocationTokenQ,
renderPackageLocationToken,
) where
import Distribution.Client.ProjectConfig.Types
......@@ -755,6 +756,8 @@ renderPackageLocationToken s | needsQuoting = show s
ok n ('{':cs) = ok (n+1) cs
ok n ('}':cs) = ok (n-1) cs
ok n (',':cs) = (n > 0) && ok n cs
ok _ (c:_)
| isSpace c = False
ok n (_ :cs) = ok n cs
......
......@@ -223,7 +223,8 @@ prop_roundtrip_printparse_specific config =
prop_parsePackageLocationTokenQ :: PackageLocationString -> Bool
prop_parsePackageLocationTokenQ (PackageLocationString str) =
case [ x | (x,"") <- Parse.readP_to_S parsePackageLocationTokenQ str ] of
case [ x | (x,"") <- Parse.readP_to_S parsePackageLocationTokenQ
(renderPackageLocationToken str) ] of
[str'] -> str' == str
_ -> False
......@@ -259,8 +260,8 @@ instance Arbitrary PackageLocationString where
arbitrary =
PackageLocationString <$>
oneof
[ --show <$> (arbitrary :: Gen String)
arbitraryGlobLikeStr
[ show . getNonEmpty <$> (arbitrary :: Gen (NonEmptyList String))
, arbitraryGlobLikeStr
, show <$> (arbitrary :: Gen URI)
]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment