Shinmera / parachute

An extensible and cross-compatible testing framework.
https://shinmera.github.io/parachute
zlib License
94 stars 9 forks source link

Help request: testing errors during macroexpansion #43

Closed tfeb closed 2 years ago

tfeb commented 2 years ago

I want to be able to test that macros are checking their syntax properly and signalling errors when they should. So given the following silly macro which wants all its arguments to be literal numbers:

(defmacro silly (&body forms)
  (unless (every #'numberp forms)
    (error "silly error"))
  `(progn ,@forms))

and a test for it

(define-test "silly"
  :compile-at :execute
  (fail (silly nil)))

Then this test will fail, because (I think?) the error happens too early for it. Is there a way of dealing with this (which does not involve manually calling macroexpand on things!).

Shinmera commented 2 years ago

Hmm, one of the issues is that compile on SBCL grabs errors and warnings instead of hitting the debugger or a handler. I'll have a look at how we can deal with this.

Shinmera commented 2 years ago

Okey, I've added a fail-compile tester that should be fit for your uses in f6698a9

tfeb commented 2 years ago

Thank you! I'll try this tomorrow (maybe today your time).