Safe Haskell | None |
---|---|
Language | Haskell98 |
Propellor.Property.Concurrent
Description
Propellor properties can be made to run concurrently, using this module. This can speed up propellor, at the expense of using more CPUs and other resources.
It's up to you to make sure that properties that you make run concurrently don't implicitly depend on one-another. The worst that can happen though, is that propellor fails to ensure some of the properties, and tells you what went wrong.
Another potential problem is that output of concurrent properties could
interleave into a scrambled mess. This is mostly prevented; all messages
output by propellor are concurrency safe, including errorMessage
,
infoMessage
, etc. However, if you write a property that directly
uses print
or putStrLn
, you can still experience this problem.
Similarly, when properties run external commands, the command's output
can be a problem for concurrency. No need to worry;
createProcess
is concurrent output safe
(it actually uses createProcessConcurrent
), and
everything else in propellor that runs external commands is built on top
of that. Of course, if you import System.Process and use it in a
property, you can bypass that and shoot yourself in the foot.
Finally, anything that directly accesses the tty can bypass these protections. That's sometimes done for eg, password prompts. A well-written property should avoid running interactive commands anyway.
Synopsis
- concurrently :: (IsProp p1, IsProp p2, Combines p1 p2, IsProp (CombinedType p1 p2)) => p1 -> p2 -> CombinedType p1 p2
- concurrentList :: SingI metatypes => IO Int -> Desc -> Props (MetaTypes metatypes) -> Property (MetaTypes metatypes)
- props :: Props UnixLike
- getNumProcessors :: IO Int
- concurrentSatisfy :: Propellor Result -> Propellor Result -> Propellor Result
Documentation
concurrently :: (IsProp p1, IsProp p2, Combines p1 p2, IsProp (CombinedType p1 p2)) => p1 -> p2 -> CombinedType p1 p2 Source #
Ensures two properties concurrently.
& foo `concurrently` bar
To ensure three properties concurrently, just use this combinator twice:
& foo `concurrently` bar `concurrently` baz
concurrentList :: SingI metatypes => IO Int -> Desc -> Props (MetaTypes metatypes) -> Property (MetaTypes metatypes) Source #
Ensures all the properties in the list, with a specified amount of concurrency.
concurrentList (pure 2) "demo" $ props & foo & bar & baz
The above example will run foo and bar concurrently, and once either of those 2 properties finishes, will start running baz.
props :: Props UnixLike Source #
Start accumulating a list of properties.
Properties can be added to it using `(&)` etc.
getNumProcessors :: IO Int #
Returns the number of CPUs that the machine has
Since: base-4.5.0.0