3 (defvar *current-configuration-stream
* nil
)
5 (defvar *current-asdf-system-name
* nil
)
7 (eval-when (:load-toplevel
:execute
)
8 (when (find-package :asdf
)
9 (defmethod asdf:perform
:around
((operation asdf
:test-op
) (c asdf
:system
))
10 (let ((*current-asdf-system-name
* (asdf:component-name c
)))
11 (call-next-method)))))
13 (defun find-generic-test-configuration ()
14 (let ((srp (and *current-asdf-system-name
*
16 (intern (symbol-name 'system-relative-pathname
) :asdf
))))
18 (or (probe-file (funcall srp
19 *current-asdf-system-name
*
21 (probe-file (funcall srp
22 *current-asdf-system-name
*
23 "lift-standard.config"))
24 (error "Unable to find lift-local.config or lift-standard.config relative to the current system (~s)" *current-asdf-system-name
*)))
26 (error "Unable to use :generic configuration option either because ASDF is not loaded or because asdf:system-relative-pathname is not bound (maybe try updating?) or because the current system cannot be determined.")))))
28 (defun run-tests-from-file (path)
29 (let ((real-path (cond ((eq path
:generic
)
30 (setf path
(find-generic-test-configuration)))
34 (error "Unable to find configuration file ~s" path
))
36 (let* ((*package
* *package
*)
38 (result (make-test-result path
:multiple
))
39 (*lift-dribble-pathname
* nil
)
40 (*lift-debug-output
* *debug-io
*)
41 (*lift-standard-output
* *standard-output
*)
42 (*test-break-on-errors?
* nil
)
43 (*test-do-children?
* t
)
44 (*lift-equality-test
* 'equal
)
45 (*test-print-length
* :follow-print
)
46 (*test-print-level
* :follow-print
)
47 (*lift-if-dribble-exists
* :append
)
48 (*test-result
* result
))
49 (%run-tests-from-file path
)))))
51 (defun %run-tests-from-file
(path)
52 (with-open-file (*current-configuration-stream
* path
54 :if-does-not-exist
:error
)
56 (loop while
(not (eq (setf form
(read *current-configuration-stream
*
60 ((error (lambda (c) (format
62 "Error while running ~a from ~a: ~a"
64 (invoke-debugger c
))))
68 (assert (typep name
'symbol
) nil
69 "Each command must be a symbol and ~s is not." name
)
70 (setf args
(massage-arguments args
))
72 ;; check for preferences first (i.e., keywords)
73 ((eq (symbol-package name
)
74 (symbol-package :keyword
))
75 ;; must be a preference
76 (handle-config-preference name args
))
77 ((subtypep (find-testsuite name
)
79 (apply #'run-tests
:suite name
80 :result
*test-result
* args
))
82 (error "Don't understand '~s' while reading from ~s"
84 (values *test-result
*))
86 (defun massage-arguments (args)
87 (loop for arg in args collect
88 (cond ((and (symbolp arg
)
89 (string= (symbol-name arg
) (symbol-name '*standard-output
*)))
93 (defmethod handle-config-preference ((name t
) args
)
94 (error "Unknown preference ~s (with arguments ~s)"
97 (defmethod handle-config-preference ((name (eql :include
)) args
)
98 (%run-tests-from-file
(merge-pathnames (first args
)
99 *current-configuration-stream
*)))
101 (defmethod handle-config-preference ((name (eql :dribble
)) args
)
102 (setf *lift-dribble-pathname
* (first args
)))
104 (defmethod handle-config-preference ((name (eql :debug-output
)) args
)
105 (setf *lift-debug-output
* (first args
)))
107 (defmethod handle-config-preference ((name (eql :standard-output
)) args
)
108 (setf *lift-standard-output
* (first args
)))
110 (defmethod handle-config-preference ((name (eql :break-on-errors?
)) args
)
111 (setf *test-break-on-errors?
* (first args
)))
113 (defmethod handle-config-preference ((name (eql :do-children?
)) args
)
114 (setf *test-do-children?
* (first args
)))
116 (defmethod handle-config-preference ((name (eql :equality-test
)) args
)
117 (setf *lift-equality-test
* (first args
)))
119 (defmethod handle-config-preference ((name (eql :print-length
)) args
)
120 (setf *test-print-length
* (first args
)))
122 (defmethod handle-config-preference ((name (eql :print-level
)) args
)
123 (setf *test-print-level
* (first args
)))
125 (defmethod handle-config-preference ((name (eql :print-suite-names
)) args
)
126 (setf *test-print-testsuite-names
* (first args
)))
128 (defmethod handle-config-preference ((name (eql :print-test-case-names
)) args
)
129 (setf *test-print-test-case-names
* (first args
)))
131 (defmethod handle-config-preference ((name (eql :if-dribble-exists
))
133 (setf *lift-if-dribble-exists
* (first args
)))
135 (defmethod handle-config-preference ((name (eql :report-property
))
137 (setf (test-result-property *test-result
* (first args
)) (second args
)))
139 (defmethod handle-config-preference ((name (eql :profiling-threshold
))
141 (setf *profiling-threshold
* (first args
)))
143 (defmethod handle-config-preference ((name (eql :build-report
))
145 (declare (ignore args
))
146 (let* ((dest (or (test-result-property *test-result
* :full-pathname
)
147 (asdf:system-relative-pathname
148 (or (test-result-property *test-result
* :relative-to
)
150 (or (test-result-property *test-result
* :name
)
152 (format (or (test-result-property *test-result
* :format
)
154 (unique-name (test-result-property *test-result
* :unique-name
)))
155 (when (and unique-name
(not (streamp dest
)))
156 (setf dest
(unique-filename dest
)))
157 (with-standard-io-syntax
158 (let ((*print-readably
* nil
))
161 ((or (streamp dest
) (writable-directory-p dest
))
162 (format *debug-io
* "~&Sending report (format ~s) to ~a"
169 (format *debug-io
* "~&Unable to write report (format ~s) to ~a"
173 "Error ~a while generating report (format ~s) to ~a"