From: Iustin Pop <[email protected]> For some reason, this test doesn't pass on Debian unstable. I don't know if it passes on other versions of QuickCheck, but upon investigation, I think it was always broken, but the use of stableCover hides it.
The problem is that the test wants min 4% coverage of the enumerated actions as applyingFilter, among which is also Continue. But according to that function's code and comments, Continue can never be the result of applyingFilter, which means that this test passes randomly only then stableCover generates 2/10 True cases (which can happen, since frequency AFAIK doesn't guarantee absolute numbers); this makes the test pass as our required percent is very low (2/10 > 1.3/10 which is what we require). Removing the 'stableCover' call and using instead 'cover' shows correctly that Cover is generated in 0% of cases (i.e. never). Therefore, let's remove Cover from the list of required actions. Additionally, slightly improve the test: instead of using '==>' and discarding post-generation the unsuited tests, directly filter them during generation, potentially making the test slightly faster. Signed-off-by: Iustin Pop <[email protected]> --- test/hs/Test/Ganeti/JQScheduler.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/hs/Test/Ganeti/JQScheduler.hs b/test/hs/Test/Ganeti/JQScheduler.hs index 04a6287..770d67e 100644 --- a/test/hs/Test/Ganeti/JQScheduler.hs +++ b/test/hs/Test/Ganeti/JQScheduler.hs @@ -520,7 +520,7 @@ case_jobFiltering = do -- `doc/design-optables.rst`. prop_jobFiltering :: Property prop_jobFiltering = - forAllShrink arbitrary shrink $ \q -> + forAllShrink (arbitrary `suchThat` (not . null . qEnqueued)) shrink $ \q -> forAllShrink (resize 4 arbitrary) shrink $ \(NonEmpty filterList) -> let running = qRunning q ++ qManipulated q @@ -545,8 +545,7 @@ prop_jobFiltering = -- Makes sure that each action appears with some probability. actionName = head . words . show - allActions = map actionName [ Accept, Continue, Pause, Reject - , RateLimit 0 ] + allActions = map actionName [ Accept, Pause, Reject, RateLimit 0 ] applyingActions = map (actionName . frAction) . mapMaybe (applyingFilter filters) $ map jJob enqueued @@ -556,9 +555,8 @@ prop_jobFiltering = [ stableCover (a `elem` applyingActions) perc ("is " ++ a) | a <- allActions ] - -- `covers` should be after `==>` and before `conjoin` (see QuickCheck - -- bugs 25 and 27). - in (enqueued /= []) ==> actionCovers $ conjoin + -- `covers` should be before `conjoin` (see QuickCheck bug 27). + in actionCovers $ conjoin [ counterexample "scheduled jobs must be subsequence" $ toRun `isSubsequenceOf` enqueued -- 2.8.1
