Skip to content

Commit

Permalink
Add test case wrt #15
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Jan 12, 2024
1 parent 9b1cc99 commit fc0c201
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
ghc: ['8.2.2', '8.4.4', '8.6.5', '8.8.4', '8.10.7', '9.0.2', '9.2.8', '9.4.5', '9.6.2']
ghc: ['8.6', '8.8', '8.10', '9.0', '9.2', '9.4', '9.6']
cabal: ['3.8.1.0']
include:
- os: macOS-latest
ghc: '9.4.5'
ghc: '9.4'
cabal: '3.8.1.0'
- os: macOS-latest
ghc: '9.6.2'
ghc: '9.6'
cabal: '3.8.1.0'
- os: windows-latest
ghc: '9.4.5'
ghc: '9.4'
cabal: '3.8.1.0'
- os: windows-latest
ghc: '9.6.2'
ghc: '9.6'
cabal: '3.8.1.0'
steps:
- uses: actions/checkout@v3
Expand All @@ -48,7 +48,8 @@ jobs:
- name: Build
run: |
set -eux
[ "$(ghc --numeric-version)" = "${{ matrix.ghc }}" ]
echo ${{ matrix.ghc }}
echo $(ghc --numeric-version)
cabal update
cabal build --enable-tests
cabal test --test-show-details=direct
Expand Down
13 changes: 13 additions & 0 deletions file-io.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,16 @@ library
other-modules: System.File.Platform

ghc-options: -Wall

test-suite T15
hs-source-dirs: tests
main-is: T15.hs
type: exitcode-stdio-1.0
default-language: Haskell2010
build-depends: base, unix, bytestring, tasty, tasty-hunit, 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

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

module Main where

import Test.Tasty
import Test.Tasty.HUnit
import System.OsPath ((</>), osp)
import qualified System.OsPath as OSP
import qualified System.File.OsPath as OSP
import System.IO
import System.IO.Temp

-- Test that we can read concurrently without file lock
-- https://github.com/hasufell/file-io/issues/15
main :: IO ()
main = withSystemTempDirectory "tar-test" $ \baseDir' -> do
baseDir <- OSP.encodeFS baseDir'
OSP.writeFile (baseDir </> [osp|foo|]) ""
defaultMain $ testGroup "All"
[ testGroup "System.File.OsPath"
$ map (\i -> testCase ("foo " <> show i) (OSP.openFile (baseDir </> [osp|foo|]) ReadMode >>= hClose)) ([0..99] :: [Int])
]

0 comments on commit fc0c201

Please sign in to comment.