Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tasty #222

Merged
merged 3 commits into from
Jan 27, 2024
Merged

Tasty #222

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
8 changes: 5 additions & 3 deletions filepath.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ test-suite filepath-tests
, bytestring >=0.11.3.0
, filepath
, os-string >=2.0.1
, QuickCheck >=2.7 && <2.15
, tasty
, tasty-quickcheck

default-language: Haskell2010
ghc-options: -Wall
Expand All @@ -133,6 +134,7 @@ test-suite filepath-equivalent-tests
Legacy.System.FilePath.Posix
Legacy.System.FilePath.Windows
TestUtil
Gen

build-depends:
, base
Expand All @@ -141,7 +143,6 @@ test-suite filepath-equivalent-tests
, generic-random
, generic-deriving
, os-string >=2.0.1
, QuickCheck >=2.7 && <2.15
, tasty
, tasty-quickcheck

Expand All @@ -162,8 +163,9 @@ test-suite abstract-filepath
, deepseq
, filepath
, os-string >=2.0.1
, QuickCheck >=2.7 && <2.15
, quickcheck-classes-base ^>=0.6.2
, tasty
, tasty-quickcheck

benchmark bench-filepath
default-language: Haskell2010
Expand Down
33 changes: 2 additions & 31 deletions tests/TestUtil.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

module TestUtil(
module TestUtil,
module Test.QuickCheck,
module Test.Tasty.QuickCheck,
module Data.List,
module Data.Maybe
) where

import Test.QuickCheck hiding ((==>))
import Test.Tasty.QuickCheck hiding ((==>))
import Data.ByteString.Short (ShortByteString)
import Data.List
import Data.Maybe
Expand All @@ -29,7 +29,6 @@ import System.OsString.Encoding.Internal
import GHC.IO.Encoding.UTF16 ( mkUTF16le )
import GHC.IO.Encoding.UTF8 ( mkUTF8 )
import GHC.IO.Encoding.Failure
import System.Environment


infixr 0 ==>
Expand Down Expand Up @@ -158,31 +157,3 @@ instance Arbitrary PosixChar where
arbitrary = PW <$> arbitrary
#endif

runTests :: [(String, Property)] -> IO ()
runTests tests = do
args <- getArgs
let count = case args of i:_ -> read i; _ -> 10000
let testNum = case args of
_:i:_
| let num = read i
, num < 0 -> drop (negate num) tests
| let num = read i
, num > 0 -> take num tests
| otherwise -> []
_ -> tests
putStrLn $ "Testing with " ++ show count ++ " repetitions"
let total' = length testNum
let showOutput x = show x{output=""} ++ "\n" ++ output x
bad <- fmap catMaybes $ forM (zip @Integer [1..] testNum) $ \(i,(msg,prop)) -> do
putStrLn $ "Test " ++ show i ++ " of " ++ show total' ++ ": " ++ msg
res <- quickCheckWithResult stdArgs{chatty=False, maxSuccess=count} prop
case res of
Success{} -> pure Nothing
bad -> do putStrLn $ showOutput bad; putStrLn "TEST FAILURE!"; pure $ Just (msg,bad)
if null bad then
putStrLn $ "Success, " ++ show total' ++ " tests passed"
else do
putStrLn $ show (length bad) ++ " FAILURES\n"
forM_ (zip @Integer [1..] bad) $ \(i,(a,b)) ->
putStrLn $ "FAILURE " ++ show i ++ ": " ++ a ++ "\n" ++ showOutput b ++ "\n"
fail $ "FAILURE, failed " ++ show (length bad) ++ " of " ++ show total' ++ " tests"
2 changes: 1 addition & 1 deletion tests/abstract-filepath/Arbitrary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import qualified System.OsString.Posix as Posix
import qualified System.OsString.Windows as Windows
import Data.ByteString ( ByteString )
import qualified Data.ByteString as ByteString
import Test.QuickCheck
import Test.Tasty.QuickCheck


instance Arbitrary OsString where
Expand Down
Loading
Loading