Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this

Silly little library on the request of Tritlo. This solution is very contrived!

Why and how

Assuming you have a bunch of QC tests like this

do
  r1 <- quickCheck p1
  r2 <- quickCheck p2
  r3 <- quickC3eck p3

Perhaps the middle test is very slow and you would only like to run the first and second test, you can achieve this by

{-# LANGUAGE TemplateHaskell #-}

$(mark [0])

do
  r1 <- sweep 0 $ quickCheck p1
  r2 <- sweep 1 $ quickCheck p2
  r3 <- sweep 0 $ quickC3eck p3

The type of sweep is

sweep :: Monad m => Int -> m a -> m (Maybe a)

When you execute this, e.g. via cabal run executable, mark will generate rewrite rules that the compiler will use to turn the above program into

do
  r1 <- fmap Just $ quickCheck p1
  r2 <- return Nothing
  r3 <- fmap Just $ quickCheck p3

Executing this program will make sure that the middle test is not run. If you want to instead run only the middle test, change the 0 in mark [0] to mark [1]. If you want to run both groups of tests, instead change it to mark [0,1].

Specifying groups to run from the command line

It is quite straight forward! We just need to do some preprocessing.

{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE CPP #-}

#ifdef GROUP
$(mark GROUP)
#else
$(mark [0])
#endif

do
  r1 <- sweep 0 $ quickCheck p1
  r2 <- sweep 1 $ quickCheck p2
  r3 <- sweep 0 $ quickC3eck p3

and then specify the group on the command line as a ghc option: cabal run --ghc-options=-DGROUP=[0,1] executable. You can also leave out the #else branch of the preprocessor macro, in which case an error will be thrown if you forget to specify the groups on the command line.

Adding this to my project

Add a cabal.project file with these contents:

packages: ./*.cabal

source-repository-package
    type: git
    location: https://github.com/Rewbert/not-tasty.git

About

This is not tasty

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages