common-lisp ASDF - Another System Definition Facility How to define a test operation for a system


Example

(in-package #:asdf-user)

(defsystem #:foo
  :components ((:file "foo"))
  :in-order-to ((asdf:test-op (asdf:load-op :foo)))
  :perform (asdf:test-op (o c)
                    (uiop:symbol-call :foo-tests 'run-tests)))

(defsystem #:foo-tests
  :name "foo-test"
  :components ((:file "tests")))

;; Afterwards to run the tests we type in the REPL
(asdf:test-system :foo)

Notes:

  • We are assuming that the system :foo-tests defines a package named "FOO-TESTS"
  • run-tests is the entry point for the test runner
  • uoip:symbol-call allows as to define a method that calls a function that hasn't been read yet. The package the function is defined in doesn't exist when we define the system