Common lisp — why isn't this symbol external?

半城伤御伤魂 提交于 2020-03-22 09:23:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!