X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-util.lisp;h=8381019c7be36d165902be558dfdd26ff3ab93ac;hb=dc2b10f2cc464b6d0003c3adc4541c3895eebbd5;hp=e49c62763e323321c47aad92ed6b4017ecbf9b5a;hpb=ad0133544b3497c34e656ba2519cee5dfd70e828;p=sbcl.git diff --git a/tests/test-util.lisp b/tests/test-util.lisp index e49c627..8381019 100644 --- a/tests/test-util.lisp +++ b/tests/test-util.lisp @@ -12,19 +12,34 @@ (defvar *break-on-failure* nil) (defvar *break-on-expected-failure* nil) -(defmacro with-test ((&key fails-on name) &body body) +(defun log-msg (&rest args) + (format *trace-output* "~&::: ") + (apply #'format *trace-output* args) + (terpri *trace-output*) + (force-output *trace-output*)) + +(defmacro with-test ((&key fails-on broken-on skipped-on name) &body body) (let ((block-name (gensym))) - `(block ,block-name - (handler-bind ((error (lambda (error) - (if (expected-failure-p ,fails-on) - (fail-test :expected-failure ',name error) - (fail-test :unexpected-failure ',name error)) - (return-from ,block-name)))) - (progn - (start-test) - ,@body - (when (expected-failure-p ,fails-on) - (fail-test :unexpected-success ',name nil))))))) + `(progn + (start-test) + (cond + ((broken-p ,broken-on) + (fail-test :skipped-broken ',name "Test broken on this platform")) + ((skipped-p ,skipped-on) + (fail-test :skipped-disabled ',name "Test disabled for this combination of platform and features")) + (t + (block ,block-name + (handler-bind ((error (lambda (error) + (if (expected-failure-p ,fails-on) + (fail-test :expected-failure ',name error) + (fail-test :unexpected-failure ',name error)) + (return-from ,block-name)))) + (progn + (log-msg "Running ~S" ',name) + ,@body + (if (expected-failure-p ,fails-on) + (fail-test :unexpected-success ',name nil) + (log-msg "Success ~S" ',name)))))))))) (defun report-test-status () (with-standard-io-syntax @@ -39,19 +54,36 @@ (setf *test-count* 0)) (incf *test-count*)) +(defun really-invoke-debugger (condition) + (with-simple-restart (continue "Continue") + (let ((*invoke-debugger-hook* *invoke-debugger-hook*)) + (enable-debugger) + (invoke-debugger condition)))) + (defun fail-test (type test-name condition) + (if (stringp condition) + (log-msg "~@<~A ~S ~:_~A~:>" + type test-name condition) + (log-msg "~@<~A ~S ~:_due to ~S: ~4I~:_\"~A\"~:>" + type test-name condition condition)) (push (list type *test-file* (or test-name *test-count*)) *failures*) - (when (or (and *break-on-failure* - (not (eq type :expected-failure))) - *break-on-expected-failure*) - (really-invoke-debugger condition))) + (unless (stringp condition) + (when (or (and *break-on-failure* + (not (eq type :expected-failure))) + *break-on-expected-failure*) + (really-invoke-debugger condition)))) (defun expected-failure-p (fails-on) (sb-impl::featurep fails-on)) -(defun really-invoke-debugger (condition) - (with-simple-restart (continue "Continue") - (let ((*invoke-debugger-hook* *invoke-debugger-hook*)) - (enable-debugger) - (invoke-debugger condition)))) +(defun broken-p (broken-on) + (sb-impl::featurep broken-on)) + +(defun skipped-p (skipped-on) + (sb-impl::featurep skipped-on)) + +(defun test-env () + (cons (format nil "SBCL_MACHINE_TYPE=~A" (machine-type)) + (cons (format nil "SBCL_SOFTWARE_TYPE=~A" (software-type)) + (posix-environ))))