如何为系统定义测试操作

(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)

笔记:

  • 我们假设系统 :foo-tests 定义了一个名为“FOO-TESTS” 的
  • run-tests 是测试跑步者的切入点
  • uoip:symbol-call 允许定义一个调用尚未读取的函数的方法。定义系统时,定义函数的包不存在