From: Marco Baringer Date: Thu, 29 Nov 2012 10:07:12 +0000 (+0100) Subject: Merge remote-tracking branch 'cddr/introspection' X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=d714f36c13cb1e81cf27fed5305bd7b0f48793ff;p=fiveam.git Merge remote-tracking branch 'cddr/introspection' Conflicts: src/suite.lisp t/tests.lisp Added cddr's changes to def-suite to the recent per-suite-fixtures changes --- d714f36c13cb1e81cf27fed5305bd7b0f48793ff diff --cc src/suite.lisp index 1942cc1,b97c94c..9ac85f0 --- a/src/suite.lisp +++ b/src/suite.lisp @@@ -16,23 -16,20 +16,26 @@@ ;;;; ** Creating Suits + (defvar *suites* (make-hash-table)) + -(defmacro def-suite (name &key description in) +(defmacro def-suite (name &key description (in nil in-p) (fixture nil fixture-p)) "Define a new test-suite named NAME. IN (a symbol), if provided, causes this suite te be nested in the suite named by IN. NB: This macro is built on top of make-suite, as such it, like make-suite, will overrwrite any existing suite -named NAME." +named NAME. + +DESCRIPTION is just a string. + +FIXTURE is the fixture argument (exactly like the :fixture argument to +def-test) to pass to tests in this suite." `(eval-when (:compile-toplevel :load-toplevel :execute) - (make-suite ',name - ,@(when description `(:description ,description)) - ,@(when in-p `(:in ',in)) - ,@(when fixture-p `(:fixture ',fixture))) + (setf (gethash ',name *suites*) + (make-suite ',name + ,@(when description `(:description ,description)) - ,@(when in `(:in ',in)))) ++ ,@(when in-p `(:in ',in)) ++ ,@(when fixture-p `(:fixture ',fixture)))) ',name)) (defmacro def-suite* (name &rest def-suite-args) diff --cc t/tests.lisp index 3592ee5,0b95b8c..e03435f --- a/t/tests.lisp +++ b/t/tests.lisp @@@ -259,14 -255,6 +259,18 @@@ (is (= 1 a)) (is (= 1 b)))) + (def-test introspection () + (is (= (length (list-all-suites)) - (hash-table-count *suites*)))) ++ (hash-table-count *suites*)))) ++ +(defvar *special-variable* nil) + +(def-fixture fixture-for-suite (value) + (progn + (setf *special-variable* value) + (&body))) + +(def-suite suite-with-fixture :fixture (fixture-for-suite 42) :in :it.bese.fiveam) + +(def-test test-with-suite-fixture (:suite suite-with-fixture) + (is (= 42 *special-variable*)))