Skip to content

Commit

Permalink
Test suite: wrap some properties in once
Browse files Browse the repository at this point in the history
Prior to `QuickCheck-2.15`, properties without any quantification (e.g.,
`quickCheck True`) would only be run a single time. This is no longer the case
in `QuickCheck-2.15` or later, as these properties will now be run multiple
times, just like properties with arguments.

We use `ioProperty` to define a small number properties without any arguments
in the `copilot-bluespec` test suite. Unfortunately, this means that we were
previously compiling and simulating, say, 7 Bluespec programs prior to
`QuickCheck-2.15`, but we now we are compiling and simulating _700_ Bluespec
programs after `QuickCheck-2.15`. This means that it takes an extraordinarily
long time to run the test suite using `QuickCheck-2.15`.

This patch restores the old behavior of pre-2.15 versions of `QuickCheck` by
wrapping these properties in `once`.
  • Loading branch information
RyanGlScott committed Jul 10, 2024
1 parent a7b9fee commit a1e48d8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tests/Test/Copilot/Compile/Bluespec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import Test.Framework.Providers.QuickCheck2 (testProperty)
import Test.QuickCheck (Arbitrary, Gen, Property,
arbitrary, choose, elements,
forAll, forAllBlind, frequency,
getPositive, ioProperty, oneof,
vectorOf, withMaxSuccess, (.&&.))
getPositive, ioProperty, once,
oneof, vectorOf, withMaxSuccess,
(.&&.))
import Test.QuickCheck.Gen (chooseAny, chooseBoundedIntegral)

-- External imports: Copilot
Expand Down Expand Up @@ -65,7 +66,7 @@ tests =

-- | Test compiling a spec.
testCompile :: Property
testCompile = ioProperty $ do
testCompile = once $ ioProperty $ do
tmpDir <- getTemporaryDirectory
setCurrentDirectory tmpDir

Expand Down Expand Up @@ -97,7 +98,7 @@ testCompile = ioProperty $ do

-- | Test compiling a spec in a custom directory.
testCompileCustomDir :: Property
testCompileCustomDir = ioProperty $ do
testCompileCustomDir = once $ ioProperty $ do
tmpDir <- getTemporaryDirectory
setCurrentDirectory tmpDir

Expand Down Expand Up @@ -135,7 +136,7 @@ testCompileCustomDir = ioProperty $ do
--
-- The actual behavior is ignored.
testRun :: Property
testRun = ioProperty $ do
testRun = once $ ioProperty $ do
tmpDir <- getTemporaryDirectory
setCurrentDirectory tmpDir

Expand Down Expand Up @@ -261,6 +262,7 @@ mkRegressionTest2 op haskellFun vals =
]
outputs = haskellFun vals1 vals2 in

once $
testRunCompareArg
inputs len outputs spec (typeBluespec t3)

Expand Down

0 comments on commit a1e48d8

Please sign in to comment.