1

我正在尝试使用 asdf 的功能从 repl 运行我的测试套件,但是当使用 quicklisps 快速加载时,如果第一次尝试加载 foo 失败,第二次加载成功。

(in-package :cl-user)
(defpackage :foo-system
  (:use :cl :asdf))
(in-package :foo-system)

(asdf:defsystem :foo
  :components ((:file "foo")))

(asdf:defsystem :foo-tests
  :depends-on (:foo)
  :components ((:file "foo-tests")))

(defmethod asdf:perform ((op test-op) (system (eql (find-system :foo))))
  (asdf:load-system 'foo-tests)
  (foo-tests:run-tests))

这是有道理的,因为当我编译 asd 文件时,错误似乎是 asdf:perfom defmethod 的第二种形式。用 foo 替换 nclack 的错误是:

../../nclack/nclack.asd:36:27:读取错误:在编译文件期间读取错误:

  Package NCLACK-TESTS does not exist.

    Line: 36, Column: 27, File-Position: 1034

    Stream: #<SB-SYS:FD-STREAM
              for "file /Users/PuercoPop/quicklisp/local-projects/nclack/nclack.asd"
              {1005DB11A3}>

与 (foo-tests:run-tests) 行匹配。因此,“加载”系统似乎与编译其形式不同?或者为什么加载系统后没有定义包?有任何想法吗?我不知所措。

4

2 回答 2

3

当你compile-file这样做时:

(defmethod asdf:perform ((op test-op) (system (eql (find-system :foo))))
  (asdf:load-system 'foo-tests)
  (foo-tests:run-tests))

第一步是read整个表格。 Reading 包括对找到的所有符号的实习。但是,在读取时,表单还没有执行,所以系统foo-tests还没有加载。由于该系统包含 package foo-tests,并且尚未加载,因此您不能在读取此表单时将任何符号实习到该包中。

这就是为什么compile-file在尝试read表单时显示错误的原因。

在我看来,你需要(funcall (find-symbol "RUN-TESTS" #:foo-tests))

于 2013-08-22T09:57:29.487 回答
0

第一的:

如果您定义一个新包FOO-SYSTEM使用该包ASDF,然后使用仍带有前缀的 asdf 符号,那么您就有点击败了该包的使用。当您为符号添加前缀时,为什么要使用它?

很难说错误是什么,因为我们看不到回溯,也看不到文件。

无论如何,您需要确保在编译文件期间包可用。例如编译一个DEFPACKAGE表单可能不会改变编译时环境。您需要执行DEFPACKAGE表格。您还需要确保在加载系统操作期间加载了包定义。

如果包不存在,则需要确保它存在。

于 2013-08-22T07:58:28.187 回答