with-expected-failure correct?
I don't think that with-expected-failure
(in "script-support.lisp") does what it should -- at least not what I expect it should (and that's the only criterion, since there's no docstring).
Here's the macro and its expansion:
(defmacro with-expected-failure ((&optional condition) &body body)
`(call-with-expected-failure ,condition (lambda () ,@body)))
(defun call-with-expected-failure (condition thunk)
(if condition
(handler-case (funcall thunk)
(:no-error (&rest x) (declare (ignore x)) (error "Unexpected success: ~A" condition))
(t (x) (declare (ignore x)) t))
(funcall thunk)))
AFAICT if condition
is nil
, then call-with-expected
failure does not check for an expected failure. So at the very least, I believe that the "else" branch should have the same handler-case
wrapped around it, just without the condition
. Otherwise ... it's just behaving like progn
, which doesn't make sense, at least not to me.
Or... oh, gosh, the condition
argument is expected to evaluate to nil
if the test is not expected to fail, and is expected to be non-nil
if the test is expected to fail.
But then... what am I supposed to make of this?
(with-expected-failure ()
(assert-pathnames-equal (directory-files (getcwd)) (list (subpathname *build-directory* "deleteme/a/1.x")))
AFAICT that means that we never expect this to fail, and if it does fail, we do nothing to quash the failure, and so with-expected-failure
is just there to confuse the reader.