set variables before executing the "test-op"
Alexey Veretennikov
txm.fourier at gmail.com
Tue Sep 6 19:49:52 UTC 2016
Hi,
Thanks,
I decided to follow your first advice with some difference:
I've created a file base.lisp with the following contents:
(in-package :cl-user)
(defpackage test.base
(:use :cl
:prove))
(in-package :test.base)
;; turn off ansi colors in report output
(setf prove.color:*enable-colors* nil)
;; change type of the reporter to Test Anything Protocol
(setf prove:*default-reporter* :tap)
and added this file to components section of the test asd file:
:components ((:module "t"
:components
((:file "base")
(:test-file "pack-test")
...
I've also added :prove to depends-on section of the test asd file.
This works for me and I don't have to modify all test files.
Is this approach ok or bad(dangerous, bad style etc.)?
Faré <fahree at gmail.com> writes:
> It's probably wrong to set those settings from your .asd file, since they may be set or reset before your
> project runs, or in between two runs.
>
> If you actually care about those variables, define a function that sets them,
> and call it at the beginning of those files.
>
> If you have a lot of files, define a class for those files that does it in its perform method for basic-load-op.
>
> As for defining accessors before the packages are interned,
> to be executed by a function run *after* they are interned,
> you can use such idioms as:
> (setf (symbol-value (find-symbol* :*enable-colors* :prove.color) nil)
> Note that find-symbol* is defined by uiop, which is :use'd by :asdf-user.
>
> Alternatively, you could (load-system :prove) in your .asd file,
> but it's ugly.
>
> —♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org
>
> On Tue, Sep 6, 2016 at 6:58 AM, Alexey Veretennikov <txm.fourier at gmail.com> wrote:
>
>
> Hi all,
>
> I am using cl-project to generate project skeleton for the library including separate asd file for unit
> tests.
> The test framework I use is the default for cl-project: prove.
> Using this framework I would like to set some special variables to control test execution _before_
> running the asdf:test-system
> i.e.
> (setf prove.color:*enable-colors* nil)
> (setf prove:*default-reporter* :tap)
>
> But the problem is when I set them directly in .asd file, the CL reader complains what the
> prove.color and prove packages do not exist (which is true, since the prove dependency is not yet
> loaded).
> I could set them in every test file, but I would like to set them globally.
> How could I set them after the dependency to unit test library (prove) is loaded and therefore
> package exists?
>
> This is what I have in .asd file for tests:
>
> :defsystem-depends-on (:prove-asdf)
>
> :perform (test-op :after (op c)
>
> (funcall (intern #.(string :run-test-system) :prove-asdf) c)
>
> (asdf:clear-system c)))
>
> Br
> /Alexey
>
>
>
--
Br,
/Alexey
More information about the asdf-devel
mailing list