问题
I'm trying to run tests in ASDF, which looks like this:
;;;; foo.asd
(defsystem "foo/tests"
:depends-on ("foo"
"fiveam")
:components ((:module "tests"
:components
((:file "main"))))
:perform (test-op (op c) (symbol-call :fiveam '#:run! 'foo/tests:all-tests))
And my tests/main.lisp
file starts off like this:
;;;; tests/main.lisp
(defpackage foo/tests
(:use :cl
:foo
:fiveam)
(:export :#run! :#all-tests))
(in-package :foo/tests)
When I run (asdf:test-system 'foo)
in my REPL, I get dropped into the debugger with a LOAD-SYSTEM-DEFINITION-ERROR
. The debugger is complaining that The symbol "ALL-TESTS" is not external in the FOO/TESTS package.
However, I am clearly exporting the symbol in the foo/tests
package. Can somebody please tell me what I'm missing here and why the Lisp compiler isn't seeing the external symbol? Thank you very much.
回答1:
The syntax for an uninterned symbol is #:foo
, not :#foo
.
You also need to resolve the symbols in the :perform
form at run-time, e. g. through uiop:find-symbol*
, just like you use uiop:symbol-call
there.
:perform (test-op (op c)
(symbol-call :fiveam '#:run!
(find-symbol* '#:all-tests '#:foo/tests)))
Or, since you seem to export a run!
function from your test package, you might want to call that instead of fiveam:run!
:
:perform (test-op (op c)
(symbol-call '#:foo/tests '#:run!))
来源:https://stackoverflow.com/questions/59978076/common-lisp-why-isnt-this-symbol-external