From f6dc3d1d5e5109c4196ad17ee69ccc7fc8b57b3b Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 10 Jan 2016 21:38:08 +0000 Subject: Fixed issue: Ram usage explodes during tests --- spec/src/Thermoprint/Printout.hs | 8 +++++--- spec/test/Thermoprint/PrintoutSpec.hs | 6 ++---- spec/thermoprint-spec.cabal | 1 + spec/thermoprint-spec.nix | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/spec/src/Thermoprint/Printout.hs b/spec/src/Thermoprint/Printout.hs index d9d9902..23a5ec1 100644 --- a/spec/src/Thermoprint/Printout.hs +++ b/spec/src/Thermoprint/Printout.hs @@ -29,7 +29,7 @@ import Data.Aeson.Types (typeMismatch) import Test.QuickCheck.Arbitrary (Arbitrary(..), CoArbitrary, genericShrink) import Test.QuickCheck.Modifiers (NonNegative(..)) -import Test.QuickCheck.Gen (oneof, suchThat) +import Test.QuickCheck.Gen (oneof, suchThat, scale) import Test.QuickCheck.Instances import Test.QuickCheck (forAll, Property) @@ -194,12 +194,14 @@ instance Arbitrary Block where shrink = genericShrink arbitrary = oneof [ Line <$> arbitrary , VSpace . getNonNegative <$> arbitrary - , NewlSep <$> arbitrary + , NewlSep <$> scale' arbitrary ] instance Arbitrary Line where shrink = genericShrink arbitrary = oneof [ Word . TL.filter (not . isSpace) <$> arbitrary -- 'isSpace '\n' == True' , HSpace . getNonNegative <$> arbitrary - , SpaceSep <$> arbitrary + , SpaceSep <$> scale' arbitrary ] + +scale' = scale (round . sqrt . fromInteger . toInteger) diff --git a/spec/test/Thermoprint/PrintoutSpec.hs b/spec/test/Thermoprint/PrintoutSpec.hs index b92d76a..7ba3656 100644 --- a/spec/test/Thermoprint/PrintoutSpec.hs +++ b/spec/test/Thermoprint/PrintoutSpec.hs @@ -9,8 +9,6 @@ import Thermoprint.Printout import Data.Aeson (fromJSON, ToJSON(..), Result(..)) import Data.Function (on) -import Control.DeepSeq (($!!), force) - -- Equality via cotext on Block instance Eq Block where (==) = (==) `on` cotext @@ -20,7 +18,7 @@ deriving instance Eq Chunk spec :: Spec spec = do prop "prop_text" prop_text - prop "json" prop_json + parallel $ prop "json" prop_json where prop_json :: Printout -> Bool - prop_json p = force $ (== Success p) . fromJSON . toJSON $!! p + prop_json p = (== Success p) . fromJSON . toJSON $ p diff --git a/spec/thermoprint-spec.cabal b/spec/thermoprint-spec.cabal index 426244e..f7227ca 100644 --- a/spec/thermoprint-spec.cabal +++ b/spec/thermoprint-spec.cabal @@ -45,6 +45,7 @@ Test-Suite tests type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Spec.hs + ghc-options: -threaded -with-rtsopts=-N build-depends: base >=4.8.1 && <5 , thermoprint-spec -any , hspec >=2.2.1 && <3 diff --git a/spec/thermoprint-spec.nix b/spec/thermoprint-spec.nix index ea903ba..2da5d86 100644 --- a/spec/thermoprint-spec.nix +++ b/spec/thermoprint-spec.nix @@ -12,7 +12,7 @@ mkDerivation { text ]; testHaskellDepends = [ - base hspec QuickCheck quickcheck-instances + aeson base hspec QuickCheck quickcheck-instances ]; homepage = "http://dirty-haskell.org/tags/thermoprint.html"; description = "A specification of the API and the payload datatypes and associated utilities"; -- cgit v1.2.3