常见的口齿不清-为什么这个符号不是外部的? [英] Common lisp — why isn't this symbol external?
问题描述
我正在尝试在ASDF中运行测试,如下所示:
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))
我的tests/main.lisp
文件开始像这样:
;;;; tests/main.lisp
(defpackage foo/tests
(:use :cl
:foo
:fiveam)
(:export :#run! :#all-tests))
(in-package :foo/tests)
在REPL中运行(asdf:test-system 'foo)
时,使用LOAD-SYSTEM-DEFINITION-ERROR
进入调试器.调试器抱怨The symbol "ALL-TESTS" is not external in the FOO/TESTS package.
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.
但是,很明显,我正在将符号导出到foo/tests
包中.有人可以告诉我我在这里缺少什么,为什么Lisp编译器看不到外部符号?非常感谢.
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.
推荐答案
未隔离符号的语法为#:foo
,而不是:#foo
.
The syntax for an uninterned symbol is #:foo
, not :#foo
.
您还需要在运行时解析:perform
表单中的符号. G.通过uiop:find-symbol*
,就像您在此处使用uiop:symbol-call
.
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)))
或者,由于您似乎从测试包中导出了run!
函数,因此您可能希望调用该函数而不是fiveam:run!
:
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!))
这篇关于常见的口齿不清-为什么这个符号不是外部的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!