[commit: packages/directory] master: Remove withWorkingDirectory from tests/Util.hs (cfb7673)

git at git.haskell.org git at git.haskell.org
Fri Dec 18 09:52:06 UTC 2015


Repository : ssh://git@git.haskell.org/directory

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/cfb7673bcacd113dbc5bbb4ddd4f89876d421d53/directory

>---------------------------------------------------------------

commit cfb7673bcacd113dbc5bbb4ddd4f89876d421d53
Author: Phil Ruffwind <rf at rufflewind.com>
Date:   Fri Jun 12 01:34:45 2015 -0400

    Remove withWorkingDirectory from tests/Util.hs


>---------------------------------------------------------------

cfb7673bcacd113dbc5bbb4ddd4f89876d421d53
 tests/Util.hs | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/tests/Util.hs b/tests/Util.hs
index 68744f9..b0db8cd 100644
--- a/tests/Util.hs
+++ b/tests/Util.hs
@@ -12,10 +12,10 @@ import Control.Concurrent.MVar (newEmptyMVar, putMVar, readMVar)
 import Control.Exception (SomeException, bracket_, catch,
                           mask, onException, try)
 import Control.Monad (Monad(..), unless, when)
-import System.Directory (createDirectory, getCurrentDirectory, makeAbsolute,
-                         removeDirectoryRecursive, setCurrentDirectory)
+import System.Directory (createDirectory, makeAbsolute,
+                         removeDirectoryRecursive, withCurrentDirectory)
 import System.Exit (exitFailure)
-import System.FilePath (FilePath, (</>), normalise)
+import System.FilePath (FilePath, normalise)
 import System.IO (IO, hFlush, hPutStrLn, putStrLn, stderr, stdout)
 import System.IO.Error (IOError, isDoesNotExistError,
                         ioError, tryIOError, userError)
@@ -124,12 +124,6 @@ expectIOErrorType t file line context which action = do
             | otherwise -> Left  ["got wrong exception: ", show e]
     Right _             -> Left  ["did not throw an exception"]
 
-withWorkingDirectory :: FilePath -> IO a -> IO a
-withWorkingDirectory dir action = do
-  cur  <- getCurrentDirectory
-  bracket_ (setCurrentDirectory (cur </> dir))
-           (setCurrentDirectory  cur) action
-
 withNewDirectory :: FilePath -> IO a -> IO a
 withNewDirectory dir action = do
   dir' <- makeAbsolute dir
@@ -146,7 +140,7 @@ isolateWorkingDirectory dir action = do
     unless (isDoesNotExistError e) $
       ioError e
   withNewDirectory dir' $
-    withWorkingDirectory dir' $
+    withCurrentDirectory dir' $
       action
 
 run :: TestEnv -> String -> (TestEnv -> IO ()) -> IO ()



More information about the ghc-commits mailing list