Skip to content
Snippets Groups Projects
Commit adb8b4d6 authored by Rufflewind's avatar Rufflewind Committed by Ben Gamari
Browse files

Fix CreateDirectoryIfMissing001 racing tests on OS X

It seems that, on the flavor of Mac OS X available on GitHub Actions,
InvalidArgument can be thrown by mkdir (createDirectory) when
createDirectoryIfMissing is raced against removeDirectoryRecursive.
parent 2670af08
No related branches found
No related tags found
No related merge requests found
...@@ -129,6 +129,7 @@ import Foreign.C ...@@ -129,6 +129,7 @@ import Foreign.C
import GHC.IO.Exception import GHC.IO.Exception
( IOErrorType ( IOErrorType
( InappropriateType ( InappropriateType
, InvalidArgument
, OtherError , OtherError
, UnsupportedOperation , UnsupportedOperation
) )
......
...@@ -579,10 +579,14 @@ setTimes :: FilePath -> (Maybe POSIXTime, Maybe POSIXTime) -> IO () ...@@ -579,10 +579,14 @@ setTimes :: FilePath -> (Maybe POSIXTime, Maybe POSIXTime) -> IO ()
setTimes path' (atime', mtime') = setTimes path' (atime', mtime') =
bracket (openFileHandle path' Win32.gENERIC_WRITE) bracket (openFileHandle path' Win32.gENERIC_WRITE)
Win32.closeHandle $ \ handle -> Win32.closeHandle $ \ handle ->
#if MIN_VERSION_Win32(2,12,0)
Win32.setFileTime handle Nothing (posixToWindowsTime <$> atime') (posixToWindowsTime <$> mtime')
#else
maybeWith with (posixToWindowsTime <$> atime') $ \ atime'' -> maybeWith with (posixToWindowsTime <$> atime') $ \ atime'' ->
maybeWith with (posixToWindowsTime <$> mtime') $ \ mtime'' -> maybeWith with (posixToWindowsTime <$> mtime') $ \ mtime'' ->
Win32.failIf_ not "" $ Win32.failIf_ not "" $
Win32.c_SetFileTime handle nullPtr atime'' mtime'' Win32.c_SetFileTime handle nullPtr atime'' mtime''
#endif
-- | Open the handle of an existing file or directory. -- | Open the handle of an existing file or directory.
openFileHandle :: String -> Win32.AccessMode -> IO Win32.HANDLE openFileHandle :: String -> Win32.AccessMode -> IO Win32.HANDLE
......
...@@ -58,7 +58,7 @@ Library ...@@ -58,7 +58,7 @@ Library
time >= 1.4 && < 1.12, time >= 1.4 && < 1.12,
filepath >= 1.3 && < 1.5 filepath >= 1.3 && < 1.5
if os(windows) if os(windows)
build-depends: Win32 >= 2.2.2 && < 2.12 build-depends: Win32 >= 2.2.2 && < 2.13
else else
build-depends: unix >= 2.5.1 && < 2.9 build-depends: unix >= 2.5.1 && < 2.9
......
...@@ -81,7 +81,10 @@ main _t = do ...@@ -81,7 +81,10 @@ main _t = do
-- (see bug #2924 on GHC Trac) -- (see bug #2924 on GHC Trac)
create = create =
createDirectoryIfMissing True testdir_a `catch` \ e -> createDirectoryIfMissing True testdir_a `catch` \ e ->
if isDoesNotExistError e || isPermissionError e || isInappropriateTypeError e if isDoesNotExistError e
|| isPermissionError e
|| isInappropriateTypeError e
|| ioeGetErrorType e == InvalidArgument
then return () then return ()
else ioError e else ioError e
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment