Fixed WHILE-MEASURING macro for case when CATCH-ERRORS-P argument is given
[lift.git] / test / test-maximum-problems.lisp
blob4b97c5326bd11b2938bf7eb4f3365429133912c2
1 (in-package #:lift-test)
3 (deftestsuite test-maximum-problems (lift-test)
4 ()
5 (:function
6 (do-it (name)
7 ;; catch cancel-testing-from-configuration and return current
8 ;; *test-result* (which is passe as an argument)
9 (restart-case
10 (run-tests :suite name :report-pathname nil)
11 (lift::cancel-testing-from-configuration (result)
12 :test (lambda (c) (declare (ignore c)) t)
13 result))))
14 (:dynamic-variables
15 (*test-break-on-errors?* nil)
16 (*test-break-on-failures?* nil)))
18 (addtest (test-maximum-problems)
19 all-nil
20 (let* ((*test-maximum-error-count* nil)
21 (*test-maximum-failure-count* nil)
22 (r (do-it 'test-maximum-problems-helper)))
23 (ensure-same (length (tests-run r)) 12)
24 (ensure-same (length (errors r)) 6)
25 (ensure-same (length (failures r)) 6)))
27 (addtest (test-maximum-problems)
28 max-3-failures
29 (let* ((*test-maximum-error-count* nil)
30 (*test-maximum-failure-count* 3)
31 (r (do-it 'test-maximum-problems-helper)))
32 (cond ((= (length (tests-run r)) 3)
33 (ensure-same (length (failures r)) 3))
34 ((= (length (tests-run r)) 9)
35 (ensure-same (length (errors r)) 6)
36 (ensure-same (length (failures r)) 3))
38 (ensure-null t :report "Wrong number of tests run: ~d."
39 :arguments ((length (tests-run r))))))))
41 (addtest (test-maximum-problems)
42 max-2-errors
43 (let* ((*test-maximum-error-count* 2)
44 (*test-maximum-failure-count* nil)
45 (r (do-it 'test-maximum-problems-helper)))
46 (cond ((= (length (tests-run r)) 2)
47 (ensure-same (length (errors r)) 2))
48 ((= (length (tests-run r)) 8)
49 (ensure-same (length (errors r)) 2)
50 (ensure-same (length (failures r)) 6))
52 (ensure-null t :report "Wrong number of tests run: ~d."
53 :arguments ((length (tests-run r))))))))
55 (deftestsuite test-maximum-problems-helper ()
56 ())
58 (deftestsuite test-maximum-problems-helper-failures
59 (test-maximum-problems-helper)
61 (:test (a (ensure-same 1 2)))
62 (:test (b (ensure-same 1 2)))
63 (:test (c (ensure-same 1 2)))
64 (:test (d (ensure-same 1 2)))
65 (:test (e (ensure-same 1 2)))
66 (:test (f (ensure-same 1 2))))
68 (deftestsuite test-maximum-problems-helper-errors
69 (test-maximum-problems-helper)
71 (:test (a (error "no good")))
72 (:test (b (error "no good")))
73 (:test (c (error "no good")))
74 (:test (d (error "no good")))
75 (:test (e (error "no good")))
76 (:test (f (error "no good"))))