Skip to content

Commit

Permalink
Add test case for #14
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Jan 12, 2024
1 parent fc0c201 commit d26ff29
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions file-io.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,15 @@ test-suite T15
build-depends: filepath >= 1.4.100.0 && < 1.5.0.0
ghc-options: -Wall

test-suite T14
hs-source-dirs: tests
main-is: T14.hs
type: exitcode-stdio-1.0
default-language: Haskell2010
build-depends: base, unix, bytestring, file-io, temporary
if flag(os-string)
build-depends: filepath >= 1.5.0.0, os-string >= 2.0.0
else
build-depends: filepath >= 1.4.100.0 && < 1.5.0.0
ghc-options: -Wall

22 changes: 22 additions & 0 deletions tests/T14.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}

module Main where

import Control.Exception
import System.OsPath ((</>), osp)
import qualified System.OsPath as OSP
import qualified System.File.OsPath as OSP
import System.IO.Temp

-- Test that 'readFile' does not create a file
-- https://github.com/hasufell/file-io/issues/14
main :: IO ()
main = withSystemTempDirectory "tar-test" $ \baseDir' -> do
baseDir <- OSP.encodeFS baseDir'
res <- try @SomeException $ OSP.readFile (baseDir </> [osp|foo|])
case res of
Left e -> print e >> return ()
Right _ -> fail "Unexpectedly found file 'foo'"

0 comments on commit d26ff29

Please sign in to comment.