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