Skip to content

Commit d651a59

Browse files
committed
Migrate rest to tasty
1 parent 56aba32 commit d651a59

File tree

5 files changed

+10
-71
lines changed

5 files changed

+10
-71
lines changed

filepath.cabal

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ test-suite filepath-tests
117117
, bytestring >=0.11.3.0
118118
, filepath
119119
, os-string >=2.0.1
120-
, QuickCheck >=2.7 && <2.15
120+
, tasty
121+
, tasty-quickcheck
121122

122123
default-language: Haskell2010
123124
ghc-options: -Wall
@@ -142,7 +143,6 @@ test-suite filepath-equivalent-tests
142143
, generic-random
143144
, generic-deriving
144145
, os-string >=2.0.1
145-
, QuickCheck >=2.7 && <2.15
146146
, tasty
147147
, tasty-quickcheck
148148

@@ -163,7 +163,6 @@ test-suite abstract-filepath
163163
, deepseq
164164
, filepath
165165
, os-string >=2.0.1
166-
, QuickCheck >=2.7 && <2.15
167166
, quickcheck-classes-base ^>=0.6.2
168167
, tasty
169168
, tasty-quickcheck

tests/TestUtil.hs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
module TestUtil(
66
module TestUtil,
7-
module Test.QuickCheck,
7+
module Test.Tasty.QuickCheck,
88
module Data.List,
99
module Data.Maybe
1010
) where
1111

12-
import Test.QuickCheck hiding ((==>))
12+
import Test.Tasty.QuickCheck hiding ((==>))
1313
import Data.ByteString.Short (ShortByteString)
1414
import Data.List
1515
import Data.Maybe
@@ -29,7 +29,6 @@ import System.OsString.Encoding.Internal
2929
import GHC.IO.Encoding.UTF16 ( mkUTF16le )
3030
import GHC.IO.Encoding.UTF8 ( mkUTF8 )
3131
import GHC.IO.Encoding.Failure
32-
import System.Environment
3332

3433

3534
infixr 0 ==>
@@ -158,31 +157,3 @@ instance Arbitrary PosixChar where
158157
arbitrary = PW <$> arbitrary
159158
#endif
160159

161-
runTests :: [(String, Property)] -> IO ()
162-
runTests tests = do
163-
args <- getArgs
164-
let count = case args of i:_ -> read i; _ -> 10000
165-
let testNum = case args of
166-
_:i:_
167-
| let num = read i
168-
, num < 0 -> drop (negate num) tests
169-
| let num = read i
170-
, num > 0 -> take num tests
171-
| otherwise -> []
172-
_ -> tests
173-
putStrLn $ "Testing with " ++ show count ++ " repetitions"
174-
let total' = length testNum
175-
let showOutput x = show x{output=""} ++ "\n" ++ output x
176-
bad <- fmap catMaybes $ forM (zip @Integer [1..] testNum) $ \(i,(msg,prop)) -> do
177-
putStrLn $ "Test " ++ show i ++ " of " ++ show total' ++ ": " ++ msg
178-
res <- quickCheckWithResult stdArgs{chatty=False, maxSuccess=count} prop
179-
case res of
180-
Success{} -> pure Nothing
181-
bad -> do putStrLn $ showOutput bad; putStrLn "TEST FAILURE!"; pure $ Just (msg,bad)
182-
if null bad then
183-
putStrLn $ "Success, " ++ show total' ++ " tests passed"
184-
else do
185-
putStrLn $ show (length bad) ++ " FAILURES\n"
186-
forM_ (zip @Integer [1..] bad) $ \(i,(a,b)) ->
187-
putStrLn $ "FAILURE " ++ show i ++ ": " ++ a ++ "\n" ++ showOutput b ++ "\n"
188-
fail $ "FAILURE, failed " ++ show (length bad) ++ " of " ++ show total' ++ " tests"

tests/abstract-filepath/Arbitrary.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import qualified System.OsString.Posix as Posix
1010
import qualified System.OsString.Windows as Windows
1111
import Data.ByteString ( ByteString )
1212
import qualified Data.ByteString as ByteString
13-
import Test.QuickCheck
13+
import Test.Tasty.QuickCheck
1414

1515

1616
instance Arbitrary OsString where

tests/abstract-filepath/OsPathSpec.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import System.OsString.Windows as WindowsS hiding (map)
2020
import Control.Exception
2121
import Data.ByteString ( ByteString )
2222
import qualified Data.ByteString as BS
23-
import Test.QuickCheck
2423
import qualified Test.QuickCheck.Classes.Base as QC
2524
import GHC.IO.Encoding.UTF8 ( mkUTF8 )
2625
import GHC.IO.Encoding.UTF16 ( mkUTF16le )

tests/filepath-tests/Test.hs

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,9 @@
1-
{-# LANGUAGE TypeApplications #-}
2-
31
module Main where
42

5-
import System.Environment
6-
import TestGen
7-
import Control.Monad
8-
import Data.Maybe
9-
import Test.QuickCheck
10-
3+
import TestGen (tests)
4+
import Test.Tasty
5+
import Test.Tasty.QuickCheck
116

127
main :: IO ()
13-
main = do
14-
args <- getArgs
15-
let count = case args of i:_ -> read i; _ -> 10000
16-
let testNum = case args of
17-
_:i:_
18-
| let num = read i
19-
, num < 0 -> drop (negate num) tests
20-
| let num = read i
21-
, num > 0 -> take num tests
22-
| otherwise -> []
23-
_ -> tests
24-
putStrLn $ "Testing with " ++ show count ++ " repetitions"
25-
let total' = length testNum
26-
let showOutput x = show x{output=""} ++ "\n" ++ output x
27-
bad <- fmap catMaybes $ forM (zip @Integer [1..] testNum) $ \(i,(msg,prop)) -> do
28-
putStrLn $ "Test " ++ show i ++ " of " ++ show total' ++ ": " ++ msg
29-
res <- quickCheckWithResult stdArgs{chatty=False, maxSuccess=count} prop
30-
case res of
31-
Success{} -> pure Nothing
32-
bad -> do putStrLn $ showOutput bad; putStrLn "TEST FAILURE!"; pure $ Just (msg,bad)
33-
if null bad then
34-
putStrLn $ "Success, " ++ show total' ++ " tests passed"
35-
else do
36-
putStrLn $ show (length bad) ++ " FAILURES\n"
37-
forM_ (zip @Integer [1..] bad) $ \(i,(a,b)) ->
38-
putStrLn $ "FAILURE " ++ show i ++ ": " ++ a ++ "\n" ++ showOutput b ++ "\n"
39-
fail $ "FAILURE, failed " ++ show (length bad) ++ " of " ++ show total' ++ " tests"
8+
main = defaultMain $ testProperties "doctests" tests
9+

0 commit comments

Comments
 (0)