[commit: packages/filepath] master: #37, let the generator take an argument of the number of tests (654be5b)

git at git.haskell.org git at git.haskell.org
Thu Mar 19 11:37:04 UTC 2015


Repository : ssh://git@git.haskell.org/filepath

On branch  : master
Link       : http://git.haskell.org/packages/filepath.git/commitdiff/654be5bc8baf2cf0efba5b176a5934323dc57832

>---------------------------------------------------------------

commit 654be5bc8baf2cf0efba5b176a5934323dc57832
Author: Neil Mitchell <ndmitchell at gmail.com>
Date:   Mon Nov 3 10:50:14 2014 +0000

    #37, let the generator take an argument of the number of tests


>---------------------------------------------------------------

654be5bc8baf2cf0efba5b176a5934323dc57832
 .ghci         | 2 +-
 tests/Test.hs | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/.ghci b/.ghci
index e9e1bba..c05f736 100644
--- a/.ghci
+++ b/.ghci
@@ -8,6 +8,6 @@ import qualified System.FilePath.Posix as P
 :def docs const $ return $ unlines [":docs_",":!start dist\\doc\\html\\filepath\\System-FilePath.html"]
 
 :def gen const $ return "Generate.main"
-:def test const $ return "Test.main"
+:def test \x -> return $ if null x then "Test.main" else "System.Environment.withArgs [" ++ show x ++ "] Test.main"
 :def go const $ return $ unlines [":reload",":gen",":reload",":test",":gen",":reload"]
 :def testfull const $ return $ unlines [":reload","gen",":reload","!cabal test"]
diff --git a/tests/Test.hs b/tests/Test.hs
index 5f8fbdc..9b96db4 100755
--- a/tests/Test.hs
+++ b/tests/Test.hs
@@ -1,6 +1,7 @@
 
 module Test(main) where
 
+import System.Environment
 import TestGen
 import Control.Monad
 import Test.QuickCheck
@@ -8,10 +9,13 @@ import Test.QuickCheck
 
 main :: IO ()
 main = do
+    args <- getArgs
+    let count = case args of i:_ -> read i; _ -> 10000
+    putStrLn $ "Testing with " ++ show count ++ " repetitions"
     let total = length tests
     bs <- forM (zip [1..] tests) $ \(i,(msg,prop)) -> do
         putStrLn $ "Test " ++ show i ++ " of " ++ show total ++ ": " ++ msg
-        res <- quickCheckWithResult stdArgs{maxSuccess=10000} prop
+        res <- quickCheckWithResult stdArgs{maxSuccess=count} prop
         case res of
             Success{} -> return True
             _ -> putStrLn "TEST FAILURE!" >> return False



More information about the ghc-commits mailing list