test-scripts.lisp 3.59 KB
Newer Older
1 2 3 4 5
(in-package :asdf-tools)

(defparameter *default-test-scripts* '("*.script"))

(defun get-test-scripts (&optional (test-scripts *test-scripts*))
6 7 8
  (typecase test-scripts
    ((eql :default) (setf test-scripts *default-test-scripts*))
    (string (setf test-scripts (ensure-list-of-strings test-scripts))))
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
  (with-asdf-dir ("test/")
    (sort
     (loop :for pattern :in test-scripts
           :append (loop :for file :in (directory* pattern)
                         :collect (enough-pathname file (pn "test/"))))
     'string< :key 'namestring)))

#|
;; Somehow we never wrote the tests that check our configuration file infrastructure...
(defun create-config ()
  (dolist (x '("build/results/" "build/test-source-registry-conf.d/"
               "build/test-asdf-output-translations-conf.d/"))
    (ensure-directories-exist (pn x))))

(defun clean-config ()
  (flet ((rm-rf (x)
           (delete-directory-tree (pn x) :validate (lambda (x) (subpathp x (pn "build/"))))))
    (rm-rf "build/test-source-registry-conf.d/")
    (rm-rf "build/test-asdf-output-translations-conf.d/")))
|#

(deftestcmd test-scripts (lisp test-scripts)
31 32
  "run test scripts
Use the preferred lisp implementation"
33
  (nest
34
   (with-asdf-dir ())
35
   (let* ((log (newlogfile "test" lisp)))
36
     (log! log "Running the following ~D ASDF test script~:*~P on ~(~A~):~%~{  ~A~%~}"
37
           (length test-scripts) lisp test-scripts))
38 39 40 41 42
   (let ((n-tests (length test-scripts))
         (test-pass 0)
         (test-fail 0)
         (failed-list ())))
   (call-without-stopping
43 44 45 46 47
    `(,(lambda ()
         (run-test-lisp
          "compiling ASDF"
          '((load "test/script-support.lisp") (asdf-test::compile-asdf-script))
          :lisp lisp :log log))
48 49 50 51 52 53 54 55 56
      ,@(mapcar
          (lambda (test-script)
            (lambda ()
              ;; TODO: do we want to delete the output file cache?
              ;; If so, we need to do it in the inferior lisp,
              ;; because only it knows for sure its output configuration.
              ;; Or we could do it in a more heavy handed way.
              ;; A better solution would be to do any output operations in a temporary workspace,
              ;; which would allow test parallelization.
57
              (if (with-failure-context (:muffle-failures t)
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
                    (run-test-lisp
                     (format nil "testing ~A on ~(~A~)" test-script lisp)
                     `((load "test/script-support.lisp")
                       (asdf-test::load-asdf)
                       (asdf-test::frob-packages)
                       (asdf-test::run-test-script ,(native-namestring (subpathname "test/" test-script))))
                     :lisp lisp :log log))
                (incf test-pass)
                (progn
                  (incf test-fail)
                  (push test-script failed-list)))))
          test-scripts)
      ,(lambda ()
         (let ((failp (plusp test-fail)))
           (log! log "~
73
-#---------------------------------------
74
Using ~(~A~)
75 76
Ran ~D tests, ~D passed, ~D failed~
~:[~%All tests apparently successful.~;:~:*~{~%  ~A~}~]
77
-#---------------------------------------~%"
78 79 80 81
                 lisp
                 n-tests test-pass test-fail (reverse failed-list))
           (when failp
             (log! log "To view full results and failures, try the following command:
82
     less -p ABORTED ~A" (enough-namestring log (pn))))
83
           (failure-if failp "~D test~:*~P failed" test-fail)))))))
84

85
(deftestcmd test (lisp test-scripts)
86 87
  "run all normal tests but upgrade tests
Use the preferred lisp implementation"
88
  (without-stopping () (test-basic lisp) (test-scripts lisp test-scripts)))
89

90
(defalias %t test)