From fdc09912d20111bc61a5be162c4728c1fb5f41ed Mon Sep 17 00:00:00 2001 From: Attila Lendvai Date: Sat, 14 Oct 2006 17:31:22 +0200 Subject: [PATCH] FIX: Store *package* at definition time for tests and rebind it at runtime --- src/classes.lisp | 4 +++- src/run.lisp | 3 ++- src/test.lisp | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) 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)))) -- 1.7.10.4