Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rio/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ when:
else:
dependencies:
- unix
- condition: os(darwin)
cpp-options: -DMACOS

library:
source-dirs: src/
Expand Down
34 changes: 27 additions & 7 deletions rio/test/RIO/FileSpec.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}

module RIO.FileSpec where

import Test.Hspec
import System.Environment (lookupEnv)
import System.FilePath ((</>))
import UnliftIO.Temporary (withSystemTempDirectory)

Expand Down Expand Up @@ -43,10 +46,27 @@ spec = do

describe "withBinaryFileDurable" $ do
context "happy path" $ do
it "works the same as withFile" $ do
withSystemTempDirectory "rio" $ \dir -> do
let fp = dir </> "with_file_durable"
SUT.withBinaryFileDurable fp WriteMode $ \h ->
BS.hPut h "Hello World"
contents <- BS.readFile fp
contents `shouldBe` "Hello World"
it "works the same as withFile" sameAsWithFiletest

sameAsWithFiletest :: IO ()
sameAsWithFiletest = do
#if !MACOS
test
#else
-- As of 2026-02-05, on GitHub macOS runners only, the file system appears to
-- reject durability-related open flags. So, we ignore the test if we
-- appear to be in that environment.
mGitHubActions <- lookupEnv "GITHUB_ACTIONS"
case mGitHubActions of
Just "true" -> pendingWith $
"On GitHub macOS runners, the file system appears to reject " <>
"durability-related open flags."
_ -> test
#endif
where
test = withSystemTempDirectory "rio" $ \dir -> do
let fp = dir </> "with_file_durable"
SUT.withBinaryFileDurable fp WriteMode $ \h ->
BS.hPut h "Hello World"
contents <- BS.readFile fp
contents `shouldBe` "Hello World"