aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatsumi Yamaoka2012-06-29 04:15:43 +0000
committerKatsumi Yamaoka2012-06-29 04:15:43 +0000
commit5437effdb836355436f5f986e46baa6a41ec0966 (patch)
tree66ad7c06561f9047b9ecfee6403f654d2d314a66
parent3e984ee810066a79ef57bbb82c925bcdd70bd334 (diff)
downloademacs-5437effdb836355436f5f986e46baa6a41ec0966.tar.gz
emacs-5437effdb836355436f5f986e46baa6a41ec0966.zip
lisp/gnus/tests/: Remove
-rw-r--r--lisp/gnus/ChangeLog4
-rw-r--r--lisp/gnus/tests/gnustest-nntp.el99
-rw-r--r--lisp/gnus/tests/gnustest-registry.el221
3 files changed, 4 insertions, 320 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index e1d3b87beb5..649b5a74fb8 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,7 @@
12012-06-29 Katsumi Yamaoka <yamaoka@jpl.org>
2
3 * tests/gnustest-nntp.el, tests/gnustest-registry.el, tests/: Remove.
4
12012-06-27 Stefan Monnier <monnier@iro.umontreal.ca> 52012-06-27 Stefan Monnier <monnier@iro.umontreal.ca>
2 6
3 * shr.el (shr-render-buffer): New command. 7 * shr.el (shr-render-buffer): New command.
diff --git a/lisp/gnus/tests/gnustest-nntp.el b/lisp/gnus/tests/gnustest-nntp.el
deleted file mode 100644
index a00a87a208f..00000000000
--- a/lisp/gnus/tests/gnustest-nntp.el
+++ /dev/null
@@ -1,99 +0,0 @@
1;;; gnustest-nntp.el --- Simple NNTP testing for Gnus
2;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
3
4;; Author: David Engster <dengste@eml.cc>
5
6;; This file is not part of GNU Emacs.
7
8;; GNU Emacs is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation; either version 3, or (at your option)
11;; any later version.
12
13;; GNU Emacs is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with GNU Emacs; see the file COPYING. If not, write to the
20;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21;; Boston, MA 02110-1301, USA.
22
23;;; Commentary:
24
25;; This test will
26;;
27;; - Fire up Gnus
28;; - Connect to Gmane
29;; - Subscribe to gmane.discuss
30;; - Get its active info
31;; - Get one specific article by message-id and check its subject
32;; - Quit Gnus
33
34;;; Code:
35
36(require 'ert)
37(require 'net-utils)
38
39(defvar gnustest-nntp-server "news.gmane.org"
40 "NNTP server used for testing.")
41
42(defun gnustest-ping-host (host)
43 "Ping HOST once and return non-nil if successful."
44 (let* ((ping-program-options '("-c" "1"))
45 (buf (ping host))
46 proc)
47 (sleep-for 0.5)
48 (with-current-buffer buf
49 (accept-process-output (get-buffer-process (current-buffer)) 2)
50 (goto-char (point-min))
51 (prog1
52 (re-search-forward ",[ ]*1.*?received,[ ]*0" nil t)
53 (when (setq proc (get-buffer-process (current-buffer)))
54 (set-process-query-on-exit-flag proc nil))
55 (kill-buffer)))))
56
57(setq gnus-home-directory (concat temporary-file-directory (make-temp-name "gnus-test-")))
58(message "***** Using %s as temporary Gnus home." gnus-home-directory)
59(mkdir gnus-home-directory)
60(setq-default gnus-init-file nil)
61
62(require 'gnus-load)
63
64(setq gnus-select-method `(nntp ,gnustest-nntp-server))
65
66
67(if (null (gnustest-ping-host gnustest-nntp-server))
68 (message "***** Skipping tests: Gmane doesn't seem to be available.")
69 ;; Server seems to be available, so start Gnus.
70 (message "***** Firing up Gnus; connecting to Gmane.")
71 (gnus)
72
73 (ert-deftest gnustest-nntp-run-simple-test ()
74 "Test Gnus with gmane.discuss."
75 (set-buffer gnus-group-buffer)
76 (gnus-group-jump-to-group "gmane.discuss")
77 (gnus-group-get-new-news-this-group 1)
78 (gnus-active "gmane.discuss")
79 (message "***** Reading active from gmane.discuss.")
80 (should (> (car (gnus-active "gmane.discuss")) 0))
81 (should (> (cdr (gnus-active "gmane.discuss")) 10000))
82 (gnus-group-unsubscribe-current-group)
83 (gnus-group-set-current-level 1 1)
84 (gnus-group-select-group 5)
85 (message "***** Getting article with certain MID and check subject.")
86 (set-buffer gnus-summary-buffer)
87 (gnus-summary-refer-article "m3mxr8pa1t.fsf@quimbies.gnus.org")
88 (should (string= (gnus-summary-article-subject) "Re: gwene idea: strip from from subject if present"))
89 (gnus-summary-exit)
90 (message "***** Quitting Gnus.")
91 (set-buffer gnus-group-buffer)
92 (gnus-group-save-newsrc)
93 (gnus-group-exit))
94)
95
96;; Local Variables:
97;; no-byte-compile: t
98;; no-update-autoloads: t
99;; End:
diff --git a/lisp/gnus/tests/gnustest-registry.el b/lisp/gnus/tests/gnustest-registry.el
deleted file mode 100644
index 914b182f705..00000000000
--- a/lisp/gnus/tests/gnustest-registry.el
+++ /dev/null
@@ -1,221 +0,0 @@
1;;; gnustest-registry.el --- Registry and Gnus registry testing for Gnus
2;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
3
4;; Author: Ted Zlatanov <tzz@lifelogs.com>
5
6;; This file is not part of GNU Emacs.
7
8;; GNU Emacs is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation; either version 3, or (at your option)
11;; any later version.
12
13;; GNU Emacs is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with GNU Emacs; see the file COPYING. If not, write to the
20;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21;; Boston, MA 02110-1301, USA.
22
23;;; Commentary:
24
25;;; Code:
26
27(eval-when-compile
28 (when (null (ignore-errors (require 'ert)))
29 (defmacro* ert-deftest (name () &body docstring-keys-and-body))))
30
31(ignore-errors
32 (require 'ert))
33
34(require 'registry)
35(require 'gnus-registry)
36
37(ert-deftest gnustest-registry-instantiation-test ()
38 (should (registry-db "Testing")))
39
40(ert-deftest gnustest-registry-match-test ()
41 (let ((entry '((hello "goodbye" "bye") (blank))))
42
43 (message "Testing :regex matching")
44 (should (registry--match :regex entry '((hello "nye" "bye"))))
45 (should (registry--match :regex entry '((hello "good"))))
46 (should-not (registry--match :regex entry '((hello "nye"))))
47 (should-not (registry--match :regex entry '((hello))))
48
49 (message "Testing :member matching")
50 (should (registry--match :member entry '((hello "bye"))))
51 (should (registry--match :member entry '((hello "goodbye"))))
52 (should-not (registry--match :member entry '((hello "good"))))
53 (should-not (registry--match :member entry '((hello "nye"))))
54 (should-not (registry--match :member entry '((hello)))))
55 (message "Done with matching testing."))
56
57(defun gnustest-registry-make-testable-db (n &optional name file)
58 (let* ((db (registry-db
59 (or name "Testing")
60 :file (or file "unused")
61 :max-hard n
62 :max-soft 0 ; keep nothing not precious
63 :precious '(extra more-extra)
64 :tracked '(sender subject groups))))
65 (dotimes (i n)
66 (registry-insert db i `((sender "me")
67 (subject "about you")
68 (more-extra) ; empty data key should be pruned
69 ;; first 5 entries will NOT have this extra data
70 ,@(when (< 5 i) (list (list 'extra "more data")))
71 (groups ,(number-to-string i)))))
72 db))
73
74(ert-deftest gnustest-registry-usage-test ()
75 (let* ((n 100)
76 (db (gnustest-registry-make-testable-db n)))
77 (message "size %d" n)
78 (should (= n (registry-size db)))
79 (message "max-hard test")
80 (should-error (registry-insert db "new" '()))
81 (message "Individual lookup")
82 (should (= 58 (caadr (registry-lookup db '(1 58 99)))))
83 (message "Grouped individual lookup")
84 (should (= 3 (length (registry-lookup db '(1 58 99)))))
85 (when (boundp 'lexical-binding)
86 (message "Individual lookup (breaks before lexbind)")
87 (should (= 58
88 (caadr (registry-lookup-breaks-before-lexbind db '(1 58 99)))))
89 (message "Grouped individual lookup (breaks before lexbind)")
90 (should (= 3
91 (length (registry-lookup-breaks-before-lexbind db
92 '(1 58 99))))))
93 (message "Search")
94 (should (= n (length (registry-search db :all t))))
95 (should (= n (length (registry-search db :member '((sender "me"))))))
96 (message "Secondary index search")
97 (should (= n (length (registry-lookup-secondary-value db 'sender "me"))))
98 (should (equal '(74) (registry-lookup-secondary-value db 'groups "74")))
99 (message "Delete")
100 (should (registry-delete db '(1) t))
101 (decf n)
102 (message "Search after delete")
103 (should (= n (length (registry-search db :all t))))
104 (message "Secondary search after delete")
105 (should (= n (length (registry-lookup-secondary-value db 'sender "me"))))
106 ;; (message "Pruning")
107 ;; (let* ((tokeep (registry-search db :member '((extra "more data"))))
108 ;; (count (- n (length tokeep)))
109 ;; (pruned (registry-prune db))
110 ;; (prune-count (length pruned)))
111 ;; (message "Expecting to prune %d entries and pruned %d"
112 ;; count prune-count)
113 ;; (should (and (= count 5)
114 ;; (= count prune-count))))
115 (message "Done with usage testing.")))
116
117(ert-deftest gnustest-registry-persistence-test ()
118 (let* ((n 100)
119 (tempfile (make-temp-file "registry-persistence-"))
120 (name "persistence tester")
121 (db (gnustest-registry-make-testable-db n name tempfile))
122 size back)
123 (message "Saving to %s" tempfile)
124 (eieio-persistent-save db)
125 (setq size (nth 7 (file-attributes tempfile)))
126 (message "Saved to %s: size %d" tempfile size)
127 (should (< 0 size))
128 (with-temp-buffer
129 (insert-file-contents-literally tempfile)
130 (should (looking-at (concat ";; Object "
131 name
132 "\n;; EIEIO PERSISTENT OBJECT"))))
133 (message "Reading object back")
134 (setq back (eieio-persistent-read tempfile))
135 (should back)
136 (message "Read object back: %d keys, expected %d==%d"
137 (registry-size back) n (registry-size db))
138 (should (= (registry-size back) n))
139 (should (= (registry-size back) (registry-size db)))
140 (delete-file tempfile))
141 (message "Done with persistence testing."))
142
143(ert-deftest gnustest-gnus-registry-misc-test ()
144 (should-error (gnus-registry-extract-addresses '("" "")))
145
146 (should (equal '("Ted Zlatanov <tzz@lifelogs.com>"
147 "noname <ed@you.me>"
148 "noname <cyd@stupidchicken.com>"
149 "noname <tzz@lifelogs.com>")
150 (gnus-registry-extract-addresses
151 (concat "Ted Zlatanov <tzz@lifelogs.com>, "
152 "ed <ed@you.me>, " ; "ed" is not a valid name here
153 "cyd@stupidchicken.com, "
154 "tzz@lifelogs.com")))))
155
156(ert-deftest gnustest-gnus-registry-usage-test ()
157 (let* ((n 100)
158 (tempfile (make-temp-file "gnus-registry-persist"))
159 (db (gnus-registry-make-db tempfile))
160 (gnus-registry-db db)
161 back size)
162 (message "Adding %d keys to the test Gnus registry" n)
163 (dotimes (i n)
164 (let ((id (number-to-string i)))
165 (gnus-registry-handle-action id
166 (if (>= 50 i) "fromgroup" nil)
167 "togroup"
168 (when (>= 70 i)
169 (format "subject %d" (mod i 10)))
170 (when (>= 80 i)
171 (format "sender %d" (mod i 10))))))
172 (message "Testing Gnus registry size is %d" n)
173 (should (= n (registry-size db)))
174 (message "Looking up individual keys (registry-lookup)")
175 (should (equal (loop for e
176 in (mapcar 'cadr
177 (registry-lookup db '("20" "83" "72")))
178 collect (assq 'subject e)
179 collect (assq 'sender e)
180 collect (assq 'group e))
181 '((subject "subject 0") (sender "sender 0") (group "togroup")
182 (subject) (sender) (group "togroup")
183 (subject) (sender "sender 2") (group "togroup"))))
184
185 (message "Looking up individual keys (gnus-registry-id-key)")
186 (should (equal (gnus-registry-get-id-key "34" 'group) '("togroup")))
187 (should (equal (gnus-registry-get-id-key "34" 'subject) '("subject 4")))
188 (message "Trying to insert a duplicate key")
189 (should-error (gnus-registry-insert db "55" '()))
190 (message "Looking up individual keys (gnus-registry-get-or-make-entry)")
191 (should (gnus-registry-get-or-make-entry "22"))
192 (message "Saving the Gnus registry to %s" tempfile)
193 (should (gnus-registry-save tempfile db))
194 (setq size (nth 7 (file-attributes tempfile)))
195 (message "Saving the Gnus registry to %s: size %d" tempfile size)
196 (should (< 0 size))
197 (with-temp-buffer
198 (insert-file-contents-literally tempfile)
199 (should (looking-at (concat ";; Object "
200 "Gnus Registry"
201 "\n;; EIEIO PERSISTENT OBJECT"))))
202 (message "Reading Gnus registry back")
203 (setq back (eieio-persistent-read tempfile))
204 (should back)
205 (message "Read Gnus registry back: %d keys, expected %d==%d"
206 (registry-size back) n (registry-size db))
207 (should (= (registry-size back) n))
208 (should (= (registry-size back) (registry-size db)))
209 (delete-file tempfile)
210 (message "Pruning Gnus registry to 0 by setting :max-soft")
211 (oset db :max-soft 0)
212 (registry-prune db)
213 (should (= (registry-size db) 0)))
214 (message "Done with Gnus registry usage testing."))
215
216(provide 'gnustest-registry)
217
218;; Local Variables:
219;; no-byte-compile: t
220;; no-update-autoloads: t
221;; End: