+ `(def-test ,name (,@args) ,@body)))
+
+(defmacro def-test (name (&key (suite nil suite-p)
+ fixture
+ (compile-at :run-time)
+ depends-on
+ profile)
+ &body body)
+ "Create a test named NAME.
+
+NAME (a symbol)::
+ The name of the test.
+
+SUITE (a test name)::
+ The suite to put the test under. It defaults to *SUITE* (which
+ itself defaults to the default global suite).
+
+FIXTURE::
+ The name of the fixture to use for this test. See `WITH-FIXTURE` for
+ details on fixtures.
+
+COMPILE-AT (a keyword)::
+ When the body of this test should be compiled. By default, or when
+ `:compile-at` is `:run-time`, test bodies are only compiled before
+ they are run. Set this to to `:definition-time` to force
+ compilation, and errors/warnings, to be done at compile time.
+
+DEPENDS-ON::
+ A list, or a symbol, which specifies the relationship between this
+ test and other tests. These conditions, `AND`, `OR` and `NOT` can be
+ combined to produce complex dependencies (whethere this is something
+ you should actually be doing is a question for another day).
+
+ `(and &rest TEST-NAMES)`:::
+ This test is run only if all of the tests in TEST-NAMES have
+ passed, otherwise a single test-skipped result is generated.
+
+ `(or &rest TEST-NAMES)`:::
+ If any of TEST-NAMES has passed this test is run, otherwise a
+ test-skipped result is generated.
+
+ `(NOT TEST-NAME`:::
+ This is test is run only if TEST-NAME failed.
+
+ __a-symbol__:::
+ Shorthand for `(AND a-symbol)`
+
+PROFILE::
+ When non-`NIL` profiling information will be collected as well."
+ (check-type compile-at (member :run-time :definition-time))
+ (multiple-value-bind (forms decls docstring)
+ (parse-body body :documentation t :whole name)
+ (let* ((description (or docstring ""))
+ (body-forms (append decls forms))
+ (suite-form (if suite-p
+ (if suite
+ `(get-test ',suite)
+ nil)
+ '*suite*))
+ (effective-body (let* ((test-fixture fixture)
+ (suite-fixture (if suite-p
+ (if suite
+ (fixture (get-test suite :error t))
+ nil)
+ (if *suite*
+ (fixture *suite*)
+ nil)))
+ (effective-fixture (or test-fixture suite-fixture)))
+ (if effective-fixture
+ (destructuring-bind (name &rest args)
+ (ensure-list effective-fixture)
+ `((with-fixture ,name ,args ,@body-forms)))
+ body-forms))))