test-configuration.script 4.63 KB
Newer Older
1
;;; -*- Lisp -*-
2

3 4
(in-package :asdf)
(use-package :asdf-test)
5

6
(defparameter *tmp-directory* (subpathname *asdf-directory* "build/"))
7 8 9
(setf *central-registry* nil)

(defun under-tmp-directory (designator &optional (defaults *tmp-directory*))
10
  (namestring (subpathname defaults designator)))
11

12
(defun create-conf-files (&optional (path *tmp-directory*))
13
  (let ((v `(("conf.d/conf1.conf"
14
              ((:directory ,(under-tmp-directory "dir1/"))))
15
             ("conf.d/conf2.conf"
16
              ((:tree ,(under-tmp-directory "dir2/"))))
17 18
             ;; this is for testing the :here directive
             ("dir5/conf.conf"
19
              ((:directory (:here "dir6"))))
20
             ("dir8/conf.conf"
21 22 23
              ((:directory (:here))))
             ("dir9/dira/conf.conf"
              ((:tree (:here)))))))
24 25
    (loop
      :for (file contents) :in v
26
      :for name = (under-tmp-directory file path)
27 28 29 30 31 32
      :do
      (ensure-directories-exist name)
      (with-open-file (out name
                           :direction :output
                           :if-exists :supersede)
        (with-standard-io-syntax
33
          (format out "~{~S~%~}" contents))))))
34

35
(defparameter *tmp-asd-directories*
36 37
  (loop
    :for dir
38 39 40 41
    :in '("dir1/"                       ; foo0
          "dir2/dir3/"                  ; foo1
          "dir2/dir4/"                  ; foo2
          "dir2/"                       ; foo3
42
          ;; system here should be found because of :here directive
43
          "dir5/dir6/"                  ; foo4
44
          ;; system here should /not/ be found because of :here directive
45 46 47
          "dir5/dir7/"                  ; foo5
          "dir8/"                       ; foo6
          "dir9/dira/"                  ; foo7 should be found because of :here :tree
48
          "dir9/dira/dirc/"              ; foo8 ditto
49
          "dir9/dirb/")                 ; foo9 should /not/ be found -- not under :here :tree
50
    :collect (under-tmp-directory dir)))
51 52 53

(defun create-asd-files ()
  (loop
54
    :for d :in *tmp-asd-directories*
55 56 57 58
    :for i :from 0 :do
    (ensure-directories-exist d)
    (with-open-file (s (merge-pathnames* (format nil "foo~D.asd" i) d)
                       :direction :output
59
                       :if-exists :supersede
60
                       :if-does-not-exist :create)
61
      (format s "(defsystem :foo~D)~%" i))))
62

63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
(assert-equal (asdf::parse-output-translations-string
               (join-namestrings '("/foo" "/bar" "" "/baz" "/quux")))
              '(:output-translations ("/foo" "/bar") :inherit-configuration
                ("/baz" "/quux")))
(assert-equal (asdf::parse-output-translations-string
               (join-namestrings '("/" "")))
              '(:output-translations ("/" nil) :ignore-inherited-configuration))
(assert-equal (asdf::parse-output-translations-string
               (join-namestrings '("/" "" "")))
              '(:output-translations ("/" nil) :inherit-configuration))
(assert-equal (asdf::parse-output-translations-string
               (join-namestrings '("/" "/")))
              '(:output-translations ("/" "/") :ignore-inherited-configuration))
(assert-equal (asdf::parse-output-translations-string
               "(:output-translations (\"/\" \"/\") :ignore-inherited-configuration)")
              '(:output-translations ("/" "/") :ignore-inherited-configuration))
79

80 81
(create-asd-files)
(create-conf-files)
82

83 84
(format t "~&subdirectories of dir2/: ~S~%" (subdirectories (under-tmp-directory "dir2/")))
(assert-equal 2 (length (subdirectories (under-tmp-directory "dir2/"))))
85

86 87
(format t "~&subdirectories of dir5/: ~S~%" (subdirectories (under-tmp-directory "dir5/")))
(assert-equal 2 (length (subdirectories (under-tmp-directory "dir5/"))))
88

89 90 91 92 93 94
(initialize-source-registry
 `(:source-registry (:include ,(under-tmp-directory "conf.d/"))
                    (:include ,(under-tmp-directory "dir5/"))
                    (:include ,(under-tmp-directory "dir8/"))
                    (:include ,(under-tmp-directory "dir9/dira/"))
                    :ignore-inherited-configuration))
95

96 97 98 99 100 101 102 103 104 105 106 107
(format t "~&Source Registry: ~S~%"
        asdf::*source-registry*)
(assert (find-system :foo0 nil))
(assert (find-system :foo1 nil))
(assert (find-system :foo2 nil))
(assert (find-system :foo3 nil))
(assert (find-system :foo4 nil))
(assert (not (find-system :foo5 nil)))
(assert (find-system :foo6 nil))
(assert (find-system :foo7 nil))
(assert (find-system :foo8 nil))
(assert (not (find-system :foo9 nil)))
108

109 110 111 112 113
(format t "~&A: ~S~%B: ~S~%"
        (namestring (system-relative-pathname :foo3 "bar/baz.lisp"))
        (under-tmp-directory "dir2/bar/baz.lisp"))
(assert-equal (namestring (system-relative-pathname :foo3 "bar/baz.lisp"))
              (under-tmp-directory "dir2/bar/baz.lisp"))