Skip to content

Commit ca5b735

Browse files
committed
Use the new File functions with Path in the Handle testsuite
1 parent 050adae commit ca5b735

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

test/Streamly/Test/FileSystem/Handle.hs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,28 @@ import System.IO
2020
, hClose
2121
, hFlush
2222
, hSeek
23-
, openFile
23+
, hPutStr
2424
)
2525
import System.IO.Temp (withSystemTempDirectory)
26+
import Streamly.Internal.FileSystem.File.Utils (openFile, withFile)
2627
import Test.QuickCheck (Property, forAll, Gen, vectorOf, choose)
2728
import Test.QuickCheck.Monadic (monadicIO, assert, run)
29+
import Streamly.Internal.FileSystem.Path (Path)
2830

2931
import qualified Streamly.Data.Fold as Fold
3032
import qualified Streamly.Internal.FileSystem.Handle as Handle
3133
import qualified Streamly.Internal.Data.Stream as Stream
3234
import qualified Streamly.Internal.Data.Array as Array
3335
import qualified Streamly.Internal.Unicode.Stream as Unicode
36+
import qualified Streamly.Internal.FileSystem.Path as Path
3437

38+
import Prelude hiding (writeFile)
3539
import Test.Hspec as H
3640
import Test.Hspec.QuickCheck
3741

42+
writeFile :: Path -> String -> IO ()
43+
writeFile fpath val = withFile fpath WriteMode (flip hPutStr val)
44+
3845
maxArrLen :: Int
3946
maxArrLen = defaultChunkSize * 8
4047

@@ -63,7 +70,7 @@ testBinData = "01234567890123456789012345678901234567890123456789"
6370
executor :: (Handle -> Stream IO Char) -> IO (Stream IO Char)
6471
executor f =
6572
withSystemTempDirectory "fs_handle" $ \fp -> do
66-
let fpath = fp </> "tmp_read.txt"
73+
fpath <- Path.fromString $ fp </> "tmp_read.txt"
6774
writeFile fpath testDataLarge
6875
h <- openFile fpath ReadMode
6976
return $ f h
@@ -115,7 +122,7 @@ testWrite hfold =
115122

116123
go list =
117124
withSystemTempDirectory "fs_handle" $ \fp -> do
118-
let fpathWrite = fp </> "tmp_write.txt"
125+
fpathWrite <- Path.fromString $ fp </> "tmp_write.txt"
119126
writeFile fpathWrite ""
120127
h <- openFile fpathWrite ReadWriteMode
121128
hSeek h AbsoluteSeek 0
@@ -136,8 +143,8 @@ testWriteWithChunk =
136143

137144
go =
138145
withSystemTempDirectory "fs_handle" $ \fp -> do
139-
let fpathRead = fp </> "tmp_read.txt"
140-
fpathWrite = fp </> "tmp_write.txt"
146+
fpathRead <- Path.fromString $ fp </> "tmp_read.txt"
147+
fpathWrite <- Path.fromString $ fp </> "tmp_write.txt"
141148
writeFile fpathRead testDataLarge
142149
writeFile fpathWrite ""
143150
hr <- openFile fpathRead ReadMode
@@ -158,7 +165,7 @@ testReadChunksFromToWith from to buffSize res = monadicIO $ run go
158165

159166
go =
160167
withSystemTempDirectory "fs_handle" $ \fp -> do
161-
let fpathRead = fp </> "tmp_read.txt"
168+
fpathRead <- Path.fromString $ fp </> "tmp_read.txt"
162169
writeFile fpathRead testBinData
163170
h <- openFile fpathRead ReadMode
164171
ls <-

0 commit comments

Comments
 (0)