首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >asdf找不到包

asdf找不到包
EN

Stack Overflow用户
提问于 2020-02-03 08:23:58
回答 1查看 252关注 0票数 0

我正在尝试使用我在这里找到的指令搭建一个Common Lisp项目:http://turtleware.eu/posts/Tutorial-Working-with-FiveAM.html。我克隆了存储库,并按照文档中的说明进行操作,以便我的.asd文件、package.lisp文件以及tests/package.lisptests/main.lisp文件与说明相匹配。我运行了(asdf:test-system 'quasirpg),一切运行正常。

我将这个示例项目复制到我的实际工作文件夹中,并进行了搜索和替换,以将quasirpg的所有实例更改为foo。我运行了(asdf:test-system 'foo),REPL给我一个错误,说找不到包"FOO-TESTS“。

现在,我重新运行(asdf:test-system 'quasirpg),它以前是有效的,并且REPL给我相同的错误,即无法找到包"QUASIRPG-TESTS“。

谁能解释一下这里发生了什么,以及我如何让我的asdf包管理器找到测试包?

代码语言:javascript
复制
Thank you.
;;;; foo.asd

(asdf:defsystem #:foo
  :description "Part of the FiveAM tutorial"
  :author "Tomek 'uint' Kurcz"
  :license "GPLv3"
  :serial t
  :components ((:file "package")
               (:file "foo"))
  :in-order-to ((test-op (test-op "foo/tests"))))

(asdf:defsystem #:foo/tests
  :depends-on (:foo :fiveam)
  :components ((:module "tests"
                :serial t
                :components ((:file "package")
                             (:file "main"))))
  :perform (test-op (o s)
                    (uiop:symbol-call :fiveam :run! 'foo-tests:all-tests)))


;;;; tests/package.lisp

(defpackage #:foo-tests
  (:use :cl :fiveam)
  (:export #:run! #:all-tests))

;;;; tests/main.lisp

(in-package #:foo-tests)

(def-suite all-tests
  :description "The master suite of all foo tests.")

  ;; tests continue below
EN

回答 1

Stack Overflow用户

发布于 2020-02-04 04:25:46

我不喜欢像fiveam这样的自动化测试,但你的问题是:perform中对symbol foo-tests:all-tests的引用,它位于一个只有在系统加载之后才会存在的包中。使用find-symbol而不是quote

下面的脚本在我的机器上运行到完成(我是从你帖子中的代码片段开始的):

代码语言:javascript
复制
DIR=~/quicklisp/local-projects/foo
mkdir $DIR
cd $DIR
cat >foo.asd <<EOF
(asdf:defsystem #:foo
  :description "Part of the FiveAM tutorial"
  :author "Tomek 'uint' Kurcz"
  :license "GPLv3"
  :serial t
  :components ((:file "package")
               (:file "foo"))
  :in-order-to ((test-op (test-op "foo/tests"))))

(asdf:defsystem #:foo/tests
  :depends-on (:foo :fiveam)
  :components ((:module "tests"
                :serial t
                :components ((:file "package")
                             (:file "main"))))
  :perform (test-op (o s)
                    (uiop:symbol-call :fiveam
                      :run!
                                      (find-symbol "ALL-TESTS"
                                   "FOO"))))

EOF

touch package.lisp
touch foo.lisp

mkdir tests

cat >tests/package.lisp <<EOF
(defpackage #:foo-tests
  (:use :cl :fiveam)
  (:export #:run! #:all-tests))

EOF

cat >tests.main.lisp <<EOF
(in-package #:foo-tests)

(def-suite all-tests
  :description "The master suite of all foo tests.")
EOF

sbcl --eval '(asdf:load-system "foo")'

避免这种符号骗局是一件痛苦的事情,也是为什么我通常不会去接触asdf测试机制,我只做一些可以从repl运行的函数。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60031856

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档