Fix test suite failure on Windows

It would be better if the Arbitrary instance avoided generating impossible
filenames like "foo/c:bar", but proably this is the only place that splits
the file from the directory and then uses the file without the directory..
At least on the quickcheck properties.

Sponsored-by: Svenne Krap on Patreon
This commit is contained in:
Joey Hess 2021-08-24 14:03:29 -04:00
parent f9b92c81f6
commit 4ed36b2634
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 38 additions and 2 deletions

View file

@ -36,7 +36,7 @@ type MkViewedFile = FilePath -> ViewedFile
- So, from dir/subdir/file.foo, generate file_%dir%subdir%.foo
-}
viewedFileFromReference :: MkViewedFile
viewedFileFromReference f = concat
viewedFileFromReference f = concat $
[ escape (fromRawFilePath base)
, if null dirs then "" else "_%" ++ intercalate "%" (map escape dirs) ++ "%"
, escape $ fromRawFilePath $ S.concat extensions
@ -44,7 +44,13 @@ viewedFileFromReference f = concat
where
(path, basefile) = splitFileName f
dirs = filter (/= ".") $ map dropTrailingPathSeparator (splitPath path)
(base, extensions) = splitShortExtensions (toRawFilePath basefile)
(base, extensions) = splitShortExtensions (toRawFilePath basefile')
{- On Windows, if the filename looked like "dir/c:foo" then
- basefile would look like it contains a drive letter, which will
- not work. There cannot really be a filename like that, probably,
- but it prevents the test suite failing. -}
(_basedrive, basefile') = splitDrive basefile
{- To avoid collisions with filenames or directories that contain
- '%', and to allow the original directories to be extracted