Add function list-all-suites
authorAndy Chambers <achambers@mcna.net>
Sun, 4 Nov 2012 17:34:28 +0000 (12:34 -0500)
committerAndy Chambers <achambers@mcna.net>
Sun, 4 Nov 2012 17:34:28 +0000 (12:34 -0500)
src/package.lisp
src/suite.lisp
t/tests.lisp

index 4183f11..2236081 100644 (file)
@@ -72,7 +72,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 972e1f6..b97c94c 100644 (file)
@@ -16,6 +16,8 @@
 
 ;;;; ** Creating Suits
 
+(defvar *suites* (make-hash-table))
+
 (defmacro def-suite (name &key description in)
   "Define a new test-suite named NAME.
 
@@ -24,9 +26,10 @@ 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."
   `(eval-when (:compile-toplevel :load-toplevel :execute)
-     (make-suite ',name
-                 ,@(when description `(:description ,description))
-                 ,@(when in `(:in ',in)))
+     (setf (gethash ',name *suites*)
+           (make-suite ',name
+                       ,@(when description `(:description ,description))
+                       ,@(when in `(:in ',in))))
      ',name))
 
 (defmacro def-suite* (name &rest def-suite-args)
@@ -52,6 +55,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 6bef836..0b95b8c 100644 (file)
   (for-all (((a b) (dummy-mv-generator)))
     (is (= 1 a))
     (is (= 1 b))))
+
+(def-test introspection ()
+  (is (= (length (list-all-suites))
+         (hash-table-count *suites*))))
\ No newline at end of file