From: Attila Lendvai Date: Sat, 14 Oct 2006 15:31:22 +0000 (+0200) Subject: FIX: Store *package* at definition time for tests and rebind it at runtime X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=fdc09912d20111bc61a5be162c4728c1fb5f41ed;p=fiveam.git FIX: Store *package* at definition time for tests and rebind it at runtime --- diff --git a/src/classes.lisp b/src/classes.lisp index d2dcbdd..964b8db 100644 --- a/src/classes.lisp +++ b/src/classes.lisp @@ -41,7 +41,9 @@ suite) in the suite.")) (defclass test-case (testable-object) ((test-lambda :initarg :test-lambda :accessor test-lambda - :documentation "The function to run.")) + :documentation "The function to run.") + (runtime-package :initarg :runtime-package :accessor runtime-package + :documentation "By default it stores *package* from the time this test was defined (macroexpanded).")) (:documentation "A test case is a single, named, collection of checks. diff --git a/src/run.lisp b/src/run.lisp index 58877e0..dbdd4ed 100644 --- a/src/run.lisp +++ b/src/run.lisp @@ -147,7 +147,8 @@ run.")) (abort-test e) (return-from run-it result-list))))) (restart-case - (let ((*readtable* (copy-readtable))) + (let ((*readtable* (copy-readtable)) + (*package* (runtime-package test))) (funcall (test-lambda test))) (retest () :report (lambda (stream) diff --git a/src/test.lisp b/src/test.lisp index ccdcb0a..553a64e 100644 --- a/src/test.lisp +++ b/src/test.lisp @@ -54,6 +54,7 @@ SUITE defaults to the current value of *SUITE*." `(progn (setf (get-test ',name) (make-instance 'test-case :name ',name + :runtime-package ,*package* :test-lambda (lambda () (funcall (compile nil '(lambda () ,@body))))