test-deferred-warnings.script 4 KB
Newer Older
1 2
;;; -*- Lisp -*-

3 4
(in-package :asdf-test)

5 6
(enable-deferred-warnings-check)

7 8 9 10 11
(def-test-system :unintern-foo
  :components ((:file "unintern-foo")))
(def-test-system :use-foo-only
  :depends-on (:unintern-foo)
  :components ((:file "use-foo")))
12 13 14 15 16 17 18
(def-test-system :use-foo-with-wrapper
  :depends-on (:unintern-foo)
  :components ((:file "use-foo"
                :perform (compile-op :around (op c)
                                 (declare (ignorable op c))
                                 (let ((asdf:*compile-file-warnings-behaviour* :error))
                                   (call-next-method))))))
19 20 21 22 23 24 25 26 27 28 29 30 31
(def-test-system :use-then-defun-foo
  :depends-on (:unintern-foo)
  :serial t
  :components ((:file "use-foo") (:file "defun-foo")))
(def-test-system :use-then-defmacro-foo
  :depends-on (:unintern-foo)
  :serial t
  :components ((:file "use-foo") (:file "defmacro-foo")))
(def-test-system :use-setf-foo-only
  :depends-on (:unintern-foo)
  :components ((:file "use-setf-foo")))
(def-test-system :use-setf-then-defun-foo
  :depends-on (:unintern-foo)
32
  :serial t
33 34 35 36 37
  :components ((:file "use-setf-foo") (:file "defun-setf-foo")))
(def-test-system :use-setf-then-defsetf-foo
  :depends-on (:unintern-foo)
  :serial t
  :components ((:file "use-setf-foo") (:file "defsetf-foo")))
38 39
(def-test-system :undefined-variables
  :components ((:file "fun-with-undefined-locals")))
40

41
(DBG :tdw0 *compile-file-warnings-behaviour*)
42 43 44 45
(handler-bind
    ((error (lambda (c) (DBG :cfwbi-ufo c))))
  (let ((*compile-file-warnings-behaviour* :ignore))
    (load-system :use-foo-only :force t)))
46

47
(reset-session)
48 49 50 51
(handler-bind
    ((error (lambda (c) (DBG :cfwbi-ufww c))))
  (load-system :use-foo-with-wrapper :force t))

52
(reset-session)
53 54 55 56
(handler-bind
    ((error (lambda (c) (DBG :cfwbi-usfo c))))
  (let ((*compile-file-warnings-behaviour* :ignore))
    (load-system :use-setf-foo-only :force t)))
57

58
(reset-session)
59 60 61 62
(DBG :tdw1 *warnings-file-type*)
(assert
 (handler-case
     (let ((*warnings-file-type* nil))
63
       (load-system :use-foo-only :force t)
64 65 66 67 68
       t)
   (error ()
     (DBG :wftn c)
     nil)))

69
(unless *warnings-file-type*
Francois-Rene Rideau's avatar
Francois-Rene Rideau committed
70
  (leave-test "Your Lisp does not support deferred-warnings" 0))
71

72
(reset-session)
73 74 75
(assert
 (handler-case
     (let ((*compile-file-warnings-behaviour* :error))
76
       (perform 'compile-op :use-foo-only)
77 78 79
       nil)
   (compile-warned-error () t)))

80
(reset-session)
81 82 83
(assert
 (handler-case
     (let ((*compile-file-warnings-behaviour* :error))
84
       (perform 'compile-op :use-setf-foo-only)
85 86
       nil)
   (compile-warned-error () t)))
87

88
(reset-session)
89 90 91 92 93
(let ((*compile-file-warnings-behaviour* :error))
  (load-system :use-then-defun-foo))

(setf *compile-file-warnings-behaviour* :error)

94
(reset-session)
95 96 97 98 99
(load-system :use-setf-then-defun-foo)

;; FIXME: on CCL, the defmacro warning is found while loading the defmacro fasl.
;; We should probably beef up the detection in reify-deferred-warnings,
;; possibly file a bug.
100
(reset-session)
101 102 103 104 105 106 107 108
(with-expected-failure (#+clozure "CCL warns while loading, not compiling")
  (assert
   (handler-case
       (load-system :use-then-defmacro-foo :force t)
     ((or compile-file-error compile-warned-error) () t)
     ;;(t (c) (DBG :utdf0 c))
     (:no-error (&rest values) (DBG :utdf1 values) nil))))

109
(reset-session)
110 111 112 113 114 115 116
(with-expected-failure (#+clozure "CCL warns while loading, not compiling")
  (assert
   (handler-case
       (load-system :use-setf-then-defsetf-foo :force t)
     ((or compile-file-error compile-warned-error) () t)
     ;;(t (c) (DBG :ustdf0 c))
     (:no-error (&rest values) (DBG :ustdf1 values) nil))))
117

118
(reset-session)
119
(errors #+(or allegro clozure) compile-file-error
120
        #+(or cmucl scl) compile-warned-error
121 122
        #+sbcl compile-failed-error
        (let ((*compile-file-warnings-behaviour* :error))
123
          (load-system :undefined-variables :force t)))
124 125

(reset-session)
126
(errors #+(or allegro clozure) compile-file-error
127
        #+(or cmucl scl) null
128 129 130
        #+sbcl compile-failed-error
        (let ((*compile-file-warnings-behaviour* :warning))
          (load-system :undefined-variables :force t)))