Merge remote-tracking branch 'cddr/introspection'
authorMarco Baringer <mb@bese.it>
Thu, 29 Nov 2012 10:07:12 +0000 (11:07 +0100)
committerMarco Baringer <mb@bese.it>
Thu, 29 Nov 2012 10:07:12 +0000 (11:07 +0100)
Conflicts:
src/suite.lisp
t/tests.lisp

Added cddr's changes to def-suite to the recent per-suite-fixtures changes

src/package.lisp
src/suite.lisp
t/tests.lisp

index 6fda69c..09a8578 100644 (file)
@@ -74,7 +74,9 @@
    #:*debug-on-error*
    #:*debug-on-failure*
    #:*verbose-failures*
-   #:results-status))
+   #:results-status
+   ;; introspection
+   #:list-all-suites))
 
 ;;;; You can use #+5am to put your test-defining code inline with your
 ;;;; other code - and not require people to have fiveam to run your
index 1942cc1..9ac85f0 100644 (file)
@@ -16,6 +16,8 @@
 
 ;;;; ** Creating Suits
 
+(defvar *suites* (make-hash-table))
+
 (defmacro def-suite (name &key description (in nil in-p) (fixture nil fixture-p))
   "Define a new test-suite named NAME.
 
@@ -29,10 +31,11 @@ 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-p      `(:in ',in))
+                       ,@(when fixture-p `(:fixture ',fixture))))
      ',name))
 
 (defmacro def-suite* (name &rest def-suite-args)
@@ -58,6 +61,10 @@ Overrides any existing suite named NAME."
     (setf (get-test name) suite)
     suite))
 
+(defun list-all-suites ()
+  (loop for suite being the hash-value in *suites*
+       collect suite))
+
 ;;;; ** Managing the Current Suite
 
 (defvar *suite* (setf (get-test 'NIL)
index 3592ee5..e03435f 100644 (file)
     (is (= 1 a))
     (is (= 1 b))))
 
+(def-test introspection ()
+  (is (= (length (list-all-suites))
+         (hash-table-count *suites*))))
+
 (defvar *special-variable* nil)
 
 (def-fixture fixture-for-suite (value)