This commit was manufactured by cvs2svn to create branch 'elmo-
[elisp/wanderlust.git] / tests / test-dist.el
1 (require 'lunit)
2 (require 'wl)
3 (require 'cl)                           ; mapc
4
5 (luna-define-class test-dist (lunit-test-case))
6
7 ;; WL-MODULES
8 (luna-define-method test-wl-modules-exists ((case test-dist))
9   (lunit-assert
10    (null
11     (let (filename lost)
12       (mapc
13        (lambda (module)
14          (setq filename (concat (symbol-name module) ".el"))
15          (unless (file-exists-p (expand-file-name filename WLDIR))
16            (add-to-list 'lost filename)))
17        WL-MODULES)
18       lost))))
19
20 ;; ELMO-MODULES
21 (luna-define-method test-elmo-modules-exists ((case test-dist))
22   (lunit-assert
23    (null
24     (let (filename lost)
25       (mapc
26        (lambda (module)
27          (setq filename (concat (symbol-name module) ".el"))
28          (unless (file-exists-p (expand-file-name filename ELMODIR))
29            (add-to-list 'lost filename)))
30        ELMO-MODULES)
31       lost))))
32
33 ;; UTILS-MODULES
34 (luna-define-method test-util-modules-exists ((case test-dist))
35   (lunit-assert
36    (null
37     (let (filename lost)
38       (mapc
39        (lambda (module)
40          (setq filename (concat (symbol-name module) ".el"))
41          (unless (file-exists-p (expand-file-name filename UTILSDIR))
42            (add-to-list 'lost symbol)))
43        UTILS-MODULES)
44       lost))))
45
46 ;; Icons
47 (luna-define-method test-wl-icon-exists ((case test-dist))
48   (lunit-assert
49    (null
50     (let (name value lost)
51       (mapatoms
52        (lambda (symbol)
53          (setq name (symbol-name symbol))
54          (setq value (and (boundp symbol) (symbol-value symbol)))
55          (when (and (string-match "^wl-.*-icon$" name)
56                     (stringp value)
57                     (string-match "xpm$" value))
58            (unless (file-exists-p (expand-file-name value ICONDIR))
59              (add-to-list 'lost symbol)))))
60       lost))))
61
62 (luna-define-method test-version-status-icon-xpm ((case test-dist))
63   (require 'wl-demo)
64   (lunit-assert
65    (file-exists-p
66     (expand-file-name (concat (wl-demo-icon-name) ".xpm") ICONDIR))))
67
68 (luna-define-method test-version-status-icon-xbm ((case test-dist))
69   (require 'wl-demo)
70   (lunit-assert
71    (file-exists-p
72     (expand-file-name (concat (wl-demo-icon-name) ".xbm") ICONDIR))))
73
74 ;; verstion.texi
75 (luna-define-method test-texi-version ((case test-dist))
76   (require 'wl-version)
77   (lunit-assert
78    (string=
79     (product-version-string (product-find 'wl-version))
80     (with-temp-buffer
81       (insert-file-contents (expand-file-name "version.texi" DOCDIR))
82       (re-search-forward "^@set VERSION \\([0-9\.]+\\)$")
83       (match-string 1)))))
84
85 ;; version.tex
86 (luna-define-method test-refcard-version ((case test-dist))
87   (require 'wl-version)
88   (lunit-assert
89    (string=
90     (product-version-string (product-find 'wl-version))
91     (with-temp-buffer
92       (insert-file-contents (expand-file-name "version.tex" DOCDIR))
93       (re-search-forward "^\\\\def\\\\versionnumber{\\([0-9\.]+\\)}$")
94       (match-string 1)))))
95
96 ;; wl/ChangeLog
97 (luna-define-method test-version-wl-changelog ((case test-dist))
98   (require 'wl-version)
99   (lunit-assert
100    (string=
101     (product-version-string (product-find 'wl-version))
102     (with-temp-buffer
103       (insert-file-contents (expand-file-name "ChangeLog" WLDIR))
104       (re-search-forward
105        "^\t\\* Version number is increased to \\([0-9\\.]+[0-9]\\).$")
106       (match-string 1)))))
107
108 ;; elmo/ChangeLog
109 (luna-define-method test-version-elmo-changelog ((case test-dist))
110   (require 'elmo-version)
111   (lunit-assert
112    (string=
113     (product-version-string (product-find 'elmo-version))
114     (with-temp-buffer
115       (insert-file-contents (expand-file-name "ChangeLog" ELMODIR))
116       (re-search-forward
117        "^\t\\* elmo-version.el (elmo-version): Up to \\([0-9\\.]+[0-9]\\).$")
118       (match-string 1)))))
119
120 ;; ChangeLog (toplevel)
121 (luna-define-method test-version-toplevel-changelog ((case test-dist))
122   (require 'wl-version)
123   (when (and (string= (wl-version-status) "stable")
124              ;; pre release version don't check.
125              (not (string-match
126                    "pre"
127                    (product-code-name (product-find 'wl-version)))))
128     (with-temp-buffer
129       (insert-file-contents (expand-file-name "ChangeLog" "./"))
130       (re-search-forward
131        "^\t\\* \\([0-9\\.]+\\) - \"\\([^\"]+\\)\"$")
132       (lunit-assert
133        (string=
134         (product-version-string (product-find 'wl-version))
135         (match-string 1)))
136       (lunit-assert
137        (string=
138         (product-code-name (product-find 'wl-version))
139         (match-string 2))))))
140
141 ;; README, README.ja (toplevel)
142 (luna-define-method test-version-readme ((case test-dist))
143   (require 'wl-version)
144   (when (string= (wl-version-status) "stable")
145     (mapc
146      (lambda (file)
147        (with-temp-buffer
148          (insert-file-contents (expand-file-name file "./"))
149          (re-search-forward "checkout -r wl-\\([0-9]+\\)_\\([0-9]+\\) wanderlust")
150          (lunit-assert
151           (= (string-to-number (match-string 1))
152              (nth 0 (product-version (product-find 'wl-version)))))
153          (lunit-assert
154           (= (string-to-number (match-string 2))
155              (nth 1 (product-version (product-find 'wl-version)))))))
156      '("README" "README.ja"))))
157
158 ;; copyright notice
159 (luna-define-method test-wl-demo-copyright-notice ((case test-dist))
160   (require 'wl-demo)
161   (lunit-assert
162    (string-match
163     (format-time-string "%Y" (current-time))
164     wl-demo-copyright-notice)))