@@ -265,7 +265,7 @@ genValidUnicodeChar = arbitraryUnicodeChar `suchThat` isCharacter
265
265
where isCharacter x = x /= '\ 65534 ' && x /= '\ 65535 '
266
266
267
267
normalizedFilePathSpec :: Spec
268
- normalizedFilePathSpec = do
268
+ normalizedFilePathSpec = beforeAll (setFileSystemEncoding utf8) $ do
269
269
it " makes file path normalized" $ property $ forAll genFilePath $ \ fp -> do
270
270
let nfp = toNormalizedFilePath fp
271
271
fromNormalizedFilePath nfp `shouldBe` (normalise fp)
@@ -297,14 +297,15 @@ normalizedFilePathSpec = do
297
297
it " converts to NormalizedFilePath and back sucessfully" $ property $ forAll genFilePath $ \ fp -> do
298
298
let osPath = fromJust (OsPath. encodeUtf fp)
299
299
osPath' <- osPathToNormalizedFilePath osPath >>= normalizedFilePathToOsPath
300
- osPath' `shouldBe` osPath
301
-
302
- it " can not convert OsPath in non-standard encoding to NormalizedFilePath" $ do
303
- -- \184921 is an example that the raw bytes of UTF16 is not valid UTF8.
304
- -- Case like this is not very common. I found it with the help of QuickCheck.
305
- setFileSystemEncoding utf8
306
- case OsPath. encodeWith utf16be utf16be " \184921" of
307
- Left err -> throwIO err
308
- Right osPath -> do
309
- osPathToNormalizedFilePath osPath `shouldThrow` \ (_ :: IOException ) -> True
300
+ osPath' `shouldBe` OsPath. normalise osPath
301
+
302
+ it " can not convert OsPath in non-standard encoding to NormalizedFilePath" $
303
+ -- Windows always use UTF16LE, the following test case doesn't apply
304
+ when (not isWindows) $
305
+ -- \184921 is an example that the raw bytes of UTF16 is not valid UTF8.
306
+ -- Case like this is not very common. I found it with the help of QuickCheck.
307
+ case OsPath. encodeWith utf16be utf16be " \184921" of
308
+ Left err -> throwIO err
309
+ Right osPath -> do
310
+ osPathToNormalizedFilePath osPath `shouldThrow` \ (_ :: IOException ) -> True
310
311
#endif
0 commit comments