X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=sheep;a=blobdiff_plain;f=src%2Ftest%2Fmain.lisp;h=572636ef8441419a4781a0698a7c53ca35609e8b;hp=3cfb79e163d535176a4b2d3e197f766fd83304ab;hb=1ba7b00;hpb=4c8ef06ce7bff14e78e79051870291d5075c42ea diff --git a/src/test/main.lisp b/src/test/main.lisp index 3cfb79e..572636e 100644 --- a/src/test/main.lisp +++ b/src/test/main.lisp @@ -16,7 +16,10 @@ `(push (lambda () (let - ((success (funcall ,f))) + ((success + (handler-case + (funcall ,f) + (error (e) (format t "Got unexpected error in tests: ~A" e))))) (if success (format t "~c[1;32m- ~A passed~c[0m~%" #\Esc ,name #\Esc) (format t "~c[1;31m- ~A failed~c[0m~%" #\Esc ,name #\Esc)) @@ -27,8 +30,25 @@ `(deftest ,source (lambda () - (load ,source) - (ignore-errors (string= (slurp-file ,target) (docgen:export-package ,pkg)))))) + (handler-case + (progn + (load ,source) + (string= (slurp-file ,target) (docgen:export-package ,pkg))) + (docgen:validation-failure (vf) + (format t "Validation failure gotten: ~A~%" + (funcall (symbol-function (find-symbol "VALIDATION-FAILURE-MSG" :docgen)) vf))))))) + +(defmacro deffailuretest (pkg source expected) + `(deftest + ,source + (lambda () + (progn + (load ,source) + (let + ((result (docgen:validate-package ,pkg))) + (or + (equal ,expected result) + (format t " Got error:~%~S~% but expected~%~S~%" result ,expected))))))) (defmacro deffailure-func-test (name doc expected) `(deftest @@ -49,3 +69,7 @@ (format t " Got error:~%~S~% but expected~%~S~%" result ,expected)))))))) (defsuccesstest :success1 "resources/success1.lisp" "resources/success1.md") +(deffailuretest :emptydocs "resources/emptydocs.lisp" + `((:failure :emptydocs "Package EMPTYDOCS has no documentation") + (:failure ,(intern "NO-DOC-CONDITION" :emptydocs) "Symbol NO-DOC-CONDITION has no documentation") + (:failure ,(intern "NO-DOC-FUNC" :emptydocs) "Symbol NO-DOC-FUNC has no documentation")))