I'm trying to load some code that's generated by CFFI, and has some
warnings in it that I know to be benign.

I'm concerned that the code to handle warnings is not working as
expected, and the tests may not work properly.

I'm attaching a modified copy of test-deferred-warnings.script.  I set
the warnings-behavior to be :error, but the test still passes.  So would
you have a peek at this and tell me if I'm doing something wrong, or if
the tests have somehow turned into an all-pass situation?

You should be able to simply diff this against your copy to see what
I've done.  I was trying to make a check, and was surprised when it
passed.  So then I tried to make a test that I *knew* would fail, and it
still didn't.  So I'm worried that this test file isn't testing.

AFAIK those HANDLER-BIND forms don't handle the error conditions, so if
there is an error, they should cause the test to fail, but that isn't
happening for me.

thanks,
r
;;; -*- Lisp -*-

(in-package :asdf-test)

(uiop:uiop-debug)
(enable-deferred-warnings-check)

(def-test-system :unintern-foo
  :components ((:file "unintern-foo")))
(def-test-system :use-foo-only
  :depends-on (:unintern-foo)
  :components ((:file "use-foo")))
(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))))))
(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)
  :serial t
  :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")))
(def-test-system :undefined-variables
  :components ((:file "fun-with-undefined-locals")))

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

(handler-bind
    ((error (lambda (c) (DBG :cfwbi-ufww c))))
  (load-system :use-foo-with-wrapper :force t))

(handler-bind
    ((error (lambda (c) (DBG :cfwbi-usfo c))))
  (let ((*compile-file-warnings-behaviour* :ignore))
    (load-system :use-setf-foo-only :force t)))

(DBG :tdw1 *warnings-file-type*)
(assert
 (handler-case
     (let ((*warnings-file-type* nil))
       (load-system :use-foo-only :force t)
       t)
   (error ()
     (DBG :wftn c)
     nil)))

(unless *warnings-file-type*
  (leave-test "Your Lisp does not support deferred-warnings" 0))

(assert
 (handler-case
     (let ((*compile-file-warnings-behaviour* :error))
       (perform 'compile-op :use-foo-only)
       nil)
   (compile-warned-error () t)))

(assert
 (handler-case
     (let ((*compile-file-warnings-behaviour* :error))
       (perform 'compile-op :use-setf-foo-only)
       nil)
   (compile-warned-error () t)))

(let ((*compile-file-warnings-behaviour* :error))
  (load-system :use-then-defun-foo))

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

(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.
(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))))

(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))))

(errors #+(or allegro clozure) compile-file-error
        #+(or cmu scl) compile-warned-error
        #+sbcl compile-failed-error
        (let ((*compile-file-warnings-behaviour* :error))
          (load-system :undefined-variables :force t)))
(errors #+(or allegro clozure) compile-file-error
        #+(or cmu scl) null
        #+sbcl compile-failed-error
        (let ((*compile-file-warnings-behaviour* :warning))
          (load-system :undefined-variables :force t)))

Reply via email to