The attached patch adds a new option to DEFSYSTEM. This option is
:TESTS test-list
test-list = (:system system-name) | function-name system-name = keyword | string function-name = symbol | string
The function name is a string designator that denotes a function with no arguments to be called. This string will be read using the standard I/O syntax only when the test is executed. This ensures that the mechanism works once the appropriate dependencies are loaded. The system name denotes a system that will be loaded when the TEST-OP operation is invoked.
The patch can be improved with some tests done when executing DEFSYTEM instead of what it does now, which is to signal an error once the test is performed.
The usual example follows.
foo.asd:
(defsystem :foo :tests ((:system "faa")) :components ((:file "foo")))
faa.asd:
(defsystem :faa :tests ("faa::run-tests") :components ((:file "faa")))
foo.lisp:
(defpackage "FOO")
(in-package "FOO")
(defun my-cos (a) (cos a))
faa.lisp:
(defpackage "FAA")
(in-package "FAA")
(defun run-tests () (format t "~&;;;~%;;; MY-COS signals errors: ~A~%;;;" (handler-case (progn (foo::my-cos 'a) 'no) (error (c) 'yes))))