adding a global fixed timeout to quickcheck
authorbulwahn
Mon, 25 Oct 2010 21:17:11 +0200
changeset 40136 b7aa93c10833
parent 40135 abc45472e48a
child 40137 9eabcb1bfe50
adding a global fixed timeout to quickcheck
src/Tools/quickcheck.ML
--- a/src/Tools/quickcheck.ML	Mon Oct 25 21:17:10 2010 +0200
+++ b/src/Tools/quickcheck.ML	Mon Oct 25 21:17:11 2010 +0200
@@ -194,10 +194,12 @@
           val (result, new_report) = with_testers k testers
           val reports = ((k, new_report) :: reports)
         in case result of NONE => with_size (k + 1) reports | SOME q => (SOME q, reports) end);
-    val ((result, reports), exec_time) = cpu_time "quickcheck execution"
+    val ((result, reports), exec_time) =
+      TimeLimit.timeLimit (Time.fromSeconds 20) (fn () => cpu_time "quickcheck execution"
       (fn () => apfst
          (fn result => case result of NONE => NONE
-        | SOME ts => SOME (names ~~ ts)) (with_size 1 []))
+        | SOME ts => SOME (names ~~ ts)) (with_size 1 []))) ()
+      handle TimeLimit.TimeOut => error "Reached timeout during Quickcheck"
   in
     (result, ([exec_time, comp_time], if report ctxt then SOME reports else NONE))
   end;