General Lisp, asdf, tests, compilation system with different optimization levels

What I really want is the definition of the original tests:

Suppose I have an asdf system:

(defsystem simple-system
  :serial t
  :components ((:module "src"
                        :components
                        ((:file "0-package")
                         (:file "1-tests-stubs")
                         (:file "2-code") ...))))

And another system to check first:

(defsystem simple-system-tests
  :serial t
  :components ((:module "src"
                        :components
                        ((:file "0-package")
                         (:file "1-tests-real")
                         (:file "2-code") ...))))

The only difference between the two is what simple-systemI have 1-tests-stubs, where simple-system-testsI have it 1-tests-real. In 1-tests-stubsI define a macro (defmacro def-test (&rest _args) nil)that gets a "real" implementation in 1-tests-real.

Now I want to compile simple-systemwith (declare (optimize (safety 0) (debug 0) (speed 3)))and simple-system-testswith the opposite (declare (optimize (safety 3) (debug 3) (speed 0))).

How can I do this (where and how to install these ads in general terms for these two systems)?

simple-system simple-system-tests ( , /)?

, .

, , ( ?).

+4
3

:around-compile:

(defsystem simple-system
  :serial t
  :around-compile (lambda (next)
                    (proclaim '(optimize (debug 3) 
                                         (safety 3)
                                         (debug 3)
                                         (speed 0)))
                    (funcall next))
  :components ((:module "src"
                        :components
                        (...))))

( ):

, , : , * readtables * , , , , , , gensym PRNG , / , ..

, ; :around-compile .

+3

.

, ( ) :

(declare (optimize (safety 0) (debug 0) (speed 3)))

, . .

:

  • speed= 3 (2 3).

  • , , . Common Lisp , locally, , .

* (defparameter *safety* 0)

, :

*SAFETY*
* (defun foo (a) (declare (optimize (safety *safety*))) (1+ a))
; in: DEFUN FOO
;     (OPTIMIZE (SAFETY *SAFETY*))
; 
; caught WARNING:
;   Ignoring bad optimization value *SAFETY* in: (OPTIMIZE (SAFETY *SAFETY*))
; 
; compilation unit finished
;   caught 1 WARNING condition

FOO

, :

* (defun foo (a) (declare (optimize (safety #.*safety*))) (1+ a))
WARNING: redefining COMMON-LISP-USER::FOO in DEFUN

FOO

:

* (defparameter *optimization-declaration* '(declare (optimize (safety 0))))

*OPTIMIZATION-DECLARATION*
* (defun foo (a) #.*optimization-declaration* (1+ a))
WARNING: redefining COMMON-LISP-USER::FOO in DEFUN

FOO
* 
+2

I hope this is just a typo, that in these examples the same 0-package file is shared by two systems. If this is not the case, you will lose badly and it will be your fault.

0
source

Source: https://habr.com/ru/post/1683876/


All Articles