Skip to content

Commit

Permalink
Make tests buildable on GHC 9.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Nov 18, 2023
1 parent de5e379 commit 5b8197c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
1 change: 0 additions & 1 deletion cabal.haskell-ci
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
tests: <9.0
installed: -directory
5 changes: 3 additions & 2 deletions tar.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ test-suite properties
build-depends: base,
array,
bytestring >= 0.10,
bytestring-handle,
containers,
deepseq,
directory >= 1.2,
Expand All @@ -93,6 +92,8 @@ test-suite properties
tasty >= 0.10 && <1.6,
tasty-quickcheck >= 0.8 && <0.11,
time
if impl(ghc < 9.0)
build-depends: bytestring-handle < 0.2

hs-source-dirs: test

Expand Down Expand Up @@ -127,4 +128,4 @@ benchmark bench
containers,
deepseq,
time,
tasty-bench
tasty-bench < 0.4
7 changes: 7 additions & 0 deletions test/Codec/Archive/Tar/Index/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ module Codec.Archive.Tar.Index.Tests (
prop_valid,
prop_serialise_deserialise,
prop_serialiseSize,
#ifdef MIN_VERSION_bytestring_handle
prop_index_matches_tar,
#endif
prop_finalise_unfinalise,
) where

Expand Down Expand Up @@ -48,7 +50,10 @@ import Data.Maybe
import Data.Function (on)
import Control.Exception (SomeException, try, throwIO)
import Codec.Archive.Tar.Write as Tar

#ifdef MIN_VERSION_bytestring_handle
import qualified Data.ByteString.Handle as HBS
#endif

-- Not quite the properties of a finite mapping because we also have lookups
-- that result in completions.
Expand Down Expand Up @@ -170,6 +175,7 @@ data SimpleTarArchive = SimpleTarArchive {
instance Show SimpleTarArchive where
show = show . simpleTarRaw

#ifdef MIN_VERSION_bytestring_handle
prop_index_matches_tar :: SimpleTarArchive -> Property
prop_index_matches_tar sta =
ioProperty (try go >>= either (\e -> throwIO (e :: SomeException))
Expand Down Expand Up @@ -198,6 +204,7 @@ prop_index_matches_tar sta =
throwIO $ userError "Entry mismatch"
_otherwise ->
throwIO $ userError "unexpected entry types"
#endif

instance Arbitrary SimpleTarArchive where
arbitrary = do
Expand Down
4 changes: 4 additions & 0 deletions test/Properties.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE CPP #-}

module Main where

import qualified Codec.Archive.Tar.Index.Tests as Index
Expand Down Expand Up @@ -45,7 +47,9 @@ main =
testProperty "toList" Index.prop_toList,
testProperty "serialise" Index.prop_serialise_deserialise,
testProperty "size" Index.prop_serialiseSize,
#ifdef MIN_VERSION_bytestring_handle
testProperty "matches tar" Index.prop_index_matches_tar,
#endif
testProperty "unfinalise" Index.prop_finalise_unfinalise
]
]
Expand Down

0 comments on commit 5b8197c

Please sign in to comment.