Skip to content

Commit

Permalink
Remove tests with unpredictable behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkkrp committed Feb 21, 2016
1 parent 0150c06 commit 1530166
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions tests/Main.hs
Expand Up @@ -43,9 +43,7 @@ import Path.IO
import Test.Hspec
import System.Environment

#if MIN_VERSION_base(4,8,0)
import System.IO.Error
#else
#if !MIN_VERSION_base(4,8,0)
import Control.Applicative ((<$>))
#endif

Expand Down Expand Up @@ -103,34 +101,20 @@ withCurrentDirSpec = it "temporarily modifies current dir" $ \dir -> do
getCurrentDir `shouldNotReturn` dir

getHomeDirSpec :: SpecWith (Path Abs Dir)
getHomeDirSpec = do
getHomeDirSpec =
it "home dir is influenced by environment variable HOME" $ \dir ->
bracket (getEnv evar) (setEnv evar) $ \_ -> do
setEnv evar (toFilePath dir)
getHomeDir `shouldReturn` dir
#if MIN_VERSION_base(4,8,0)
context "when environment variable HOME contains nonsense" $
it "throws the right exception" $ \dir ->
bracket (getEnv evar) (setEnv evar) $ \_ -> do
setEnv evar (toFilePath $ dir </> $(mkRelDir "foo"))
getHomeDir `shouldThrow` isDoesNotExistError
#endif
where evar = "HOME"

getTempDirSpec :: SpecWith (Path Abs Dir)
getTempDirSpec = do
getTempDirSpec =
it "temp dir is influenced by environment variable TMPDIR" $ \dir ->
flip finally (unsetEnv evar) $ do
setEnv evar (toFilePath dir)
getTempDir `shouldReturn` dir
unsetEnv evar
#if MIN_VERSION_base(4,8,0)
context "when environment variable TMPDIR contains nonsense" $
it "throws the right exception" $ \dir ->
flip finally (unsetEnv evar) $ do
setEnv evar (toFilePath $ dir </> $(mkRelDir "foo"))
getTempDir `shouldThrow` isDoesNotExistError
#endif
where evar = "TMPDIR"

----------------------------------------------------------------------------
Expand Down

0 comments on commit 1530166

Please sign in to comment.