test-sysdef-asdf.script 2.93 KB
Newer Older
1
;;; -*- Lisp -*-
2

3
4
5
6
(format! t "~%Using ASDF ~A~%" (asdf-version))
(assert (version< "3.0" (asdf-version))) ;; check that we have a recent enough ASDF

(DBG "Try load ASDF with an empty configuration")
7
8
9
(initialize-source-registry
 '(:source-registry :ignore-inherited-configuration))
(load-system :asdf)
10
;; We haven't found it, and got the fallback
11
(assert-equal nil (system-source-file (find-system :asdf)))
12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
;; Bogus sysdef finding function, for the sake of testing no-load-old-version.
(defun sysdef-bogus-test-search (system)
  (declare (ignore system))
  (subpathname *test-directory* "always-error.lisp"))

(let ((*system-definition-search-functions* '(sysdef-bogus-test-search))
      (state "Didn't catch warning"))
  (DBG "Bogus attempt at loading an old ASDF: should issue a warning and ignore")
  (handler-bind
      ((simple-warning
         #'(lambda (c)
             (when (search "ASDF will ignore this configured system rather than downgrade itself."
                           (simple-condition-format-control c))
               (setf state "Caught warning")))))
      (upgrade-asdf))
  (assert-equal state "Caught warning")
  (DBG "2nd bogus attempt at loading same old ASDF: should ignore without a warning")
  (handler-bind
      ((simple-warning
         #'(lambda (c)
             (error "Should not have issued warning, but did issue:~%  ~A" c))))
    (upgrade-asdf)))

(DBG "Load ASDF with proper configuration: should find asdf.asd from the source above")
37
(initialize-source-registry
38
39
 `(:source-registry
   (:directory ,*asdf-directory*)
40
   (:directory ,*uiop-directory*)
41
   :ignore-inherited-configuration))
42
(load-system :asdf)
43
44
45
46
47
;; This time we found it, but it was skipped because the version was the same
(assert-equal nil (system-source-file (find-system :asdf)))
;; But if we cheat on our version, that should work
(setf asdf::*asdf-version* "3.0")
(load-system :asdf)
48
49
(assert-pathname-equal (subpathname *asdf-directory* "asdf.asd")
                       (system-source-file (find-system :asdf)))
50

51
(DBG "Checking that Makefile and asdf.asd are in synch")
52
53
(defun system-lisp-files (system)
  (loop :for f :in (required-components system :keep-component 'cl-source-file)
54
        :collect (namestring (enough-pathname (component-pathname f) *asdf-directory*))))
55
56
57

(defun makefile-lisp-files (target)
  (remove-if 'emptyp
58
             (split-string ;; NB: assumes GNU make
59
60
61
62
63
64
65
66
67
68
69
70
              (run-program `("make" "--quiet" "--no-print-directory" ,target)
                           :output :string :error-output t :directory *asdf-directory*)
              :separator #(#\space #\newline #\return #\tab))))

(defmacro compare-files (system target)
  `(assert-equal (system-lisp-files ,system) (makefile-lisp-files ,target)))

(DBG "Testing that the Makefile and ASDF agree on the order of UIOP files")
(compare-files :uiop "driver-files")

(DBG "Testing that the Makefile and ASDF agree on the order of ASDF/DEFSYSTEM files")
(compare-files :asdf/defsystem "defsystem-files")