jay
jay

Reputation: 1524

asdf can't find package

I'm trying to scaffold a Common Lisp project using the instructions I found here: http://turtleware.eu/posts/Tutorial-Working-with-FiveAM.html. I cloned the repo and followed the instructions in the document so that my .asd file, my package.lisp file, and my tests/package.lisp and tests/main.lisp files matched the instructions. I ran (asdf:test-system 'quasirpg) and everything worked fine.

I copied this example project to my real working folder and did a search and replace to change all instances of quasirpg to foo. I ran (asdf:test-system 'foo) and the REPL gave me an error that the package "FOO-TESTS" couldn't be found.

Now, I re-ran (asdf:test-system 'quasirpg), which worked before, and the REPL is giving me the same error, that the package "QUASIRPG-TESTS" can't be found.

Can anybody please explain what's going on here and how I get my asdf package manager to find the test packages?


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

Upvotes: 0

Views: 832

Answers (1)

pjstirling
pjstirling

Reputation: 301

I'm not a fan of automated testing like fiveam, but your problem is the reference in the :perform to the symbol foo-tests:all-tests which is in a package that won't exist until after the system is loaded. Use find-symbol instead of quote

The following script runs to completion on my machine (I started with the snippets in your post):

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")'

Avoiding this kind of symbol shenaniganery is a pain and why I wouldn't generally touch the asdf testing machinery, I just make functions that can be run from the repl.

Upvotes: 1

Related Questions