diff options
| author | Gnus developers | 2012-06-26 22:55:13 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2012-06-26 22:55:13 +0000 |
| commit | 3ea82dffd7b2c17a504e336019b70c65c198f6fa (patch) | |
| tree | bea87040cf71b7a54e3bbb8288c4ea50ec48c78c | |
| parent | 89b163db286d79b43fb5c9927fc622bbf7d2ef1a (diff) | |
| download | emacs-3ea82dffd7b2c17a504e336019b70c65c198f6fa.tar.gz emacs-3ea82dffd7b2c17a504e336019b70c65c198f6fa.zip | |
Add lisp/gnus/mm-archive.el, lisp/gnus/tests/gnustest-nntp.el, and lisp/gnus/tests/gnustest-registry.el
| -rw-r--r-- | lisp/gnus/mm-archive.el | 107 | ||||
| -rw-r--r-- | lisp/gnus/tests/gnustest-nntp.el | 94 | ||||
| -rw-r--r-- | lisp/gnus/tests/gnustest-registry.el | 216 |
3 files changed, 417 insertions, 0 deletions
diff --git a/lisp/gnus/mm-archive.el b/lisp/gnus/mm-archive.el new file mode 100644 index 00000000000..7cfa4659fd9 --- /dev/null +++ b/lisp/gnus/mm-archive.el | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | ;;; mm-archive.el --- Functions for parsing archive files as MIME | ||
| 2 | |||
| 3 | ;; Copyright (C) 2012 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 6 | ;; This file is 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 of the License, or | ||
| 11 | ;; (at your option) 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. If not, see <http://www.gnu.org/licenses/>. | ||
| 20 | |||
| 21 | ;;; Commentary: | ||
| 22 | |||
| 23 | ;;; Code: | ||
| 24 | |||
| 25 | (require 'mm-decode) | ||
| 26 | (eval-when-compile | ||
| 27 | (autoload 'gnus-recursive-directory-files "gnus-util") | ||
| 28 | (autoload 'mailcap-extension-to-mime "mailcap")) | ||
| 29 | |||
| 30 | (defvar mm-archive-decoders | ||
| 31 | '(("application/ms-tnef" t "tnef" "-f" "-" "-C") | ||
| 32 | ("application/zip" nil "unzip" "-j" "-x" "%f" "-d") | ||
| 33 | ("application/x-gtar-compressed" nil "tar" "xzf" "-" "-C") | ||
| 34 | ("application/x-tar" nil "tar" "xf" "-" "-C"))) | ||
| 35 | |||
| 36 | (defun mm-archive-decoders () mm-archive-decoders) | ||
| 37 | |||
| 38 | (defun mm-dissect-archive (handle) | ||
| 39 | (let ((decoder (cddr (assoc (car (mm-handle-type handle)) | ||
| 40 | mm-archive-decoders))) | ||
| 41 | (dir (mm-make-temp-file | ||
| 42 | (expand-file-name "emm." mm-tmp-directory) 'dir))) | ||
| 43 | (set-file-modes dir #o700) | ||
| 44 | (unwind-protect | ||
| 45 | (progn | ||
| 46 | (mm-with-unibyte-buffer | ||
| 47 | (mm-insert-part handle) | ||
| 48 | (if (member "%f" decoder) | ||
| 49 | (let ((file (expand-file-name "mail.zip" dir))) | ||
| 50 | (write-region (point-min) (point-max) file nil 'silent) | ||
| 51 | (setq decoder (copy-sequence decoder)) | ||
| 52 | (setcar (member "%f" decoder) file) | ||
| 53 | (apply 'call-process (car decoder) nil nil nil | ||
| 54 | (append (cdr decoder) (list dir))) | ||
| 55 | (delete-file file)) | ||
| 56 | (apply 'call-process-region (point-min) (point-max) (car decoder) | ||
| 57 | nil (get-buffer-create "*tnef*") | ||
| 58 | nil (append (cdr decoder) (list dir))))) | ||
| 59 | `("multipart/mixed" | ||
| 60 | ,handle | ||
| 61 | ,@(mm-archive-list-files (gnus-recursive-directory-files dir)))) | ||
| 62 | (delete-directory dir t)))) | ||
| 63 | |||
| 64 | (defun mm-archive-list-files (files) | ||
| 65 | (let ((handles nil) | ||
| 66 | type disposition) | ||
| 67 | (dolist (file files) | ||
| 68 | (with-temp-buffer | ||
| 69 | (when (string-match "\\.\\([^.]+\\)$" file) | ||
| 70 | (setq type (mailcap-extension-to-mime (match-string 1 file)))) | ||
| 71 | (unless type | ||
| 72 | (setq type "application/octet-stream")) | ||
| 73 | (setq disposition | ||
| 74 | (if (string-match "^image/\\|^text/" type) | ||
| 75 | "inline" | ||
| 76 | "attachment")) | ||
| 77 | (insert (format "Content-type: %s\n" type)) | ||
| 78 | (insert "Content-Transfer-Encoding: 8bit\n\n") | ||
| 79 | (insert-file-contents file) | ||
| 80 | (push | ||
| 81 | (mm-make-handle (mm-copy-to-buffer) | ||
| 82 | (list type) | ||
| 83 | '8bit nil | ||
| 84 | `(,disposition (filename . ,file)) | ||
| 85 | nil nil nil) | ||
| 86 | handles))) | ||
| 87 | handles)) | ||
| 88 | |||
| 89 | (defun mm-archive-dissect-and-inline (handle) | ||
| 90 | (let ((start (point-marker))) | ||
| 91 | (save-restriction | ||
| 92 | (narrow-to-region (point) (point)) | ||
| 93 | (dolist (handle (cddr (mm-dissect-archive handle))) | ||
| 94 | (goto-char (point-max)) | ||
| 95 | (mm-display-inline handle)) | ||
| 96 | (goto-char (point-max)) | ||
| 97 | (mm-handle-set-undisplayer | ||
| 98 | handle | ||
| 99 | `(lambda () | ||
| 100 | (let ((inhibit-read-only t) | ||
| 101 | (end ,(point-marker))) | ||
| 102 | (remove-images ,start end) | ||
| 103 | (delete-region ,start end))))))) | ||
| 104 | |||
| 105 | (provide 'mm-archive) | ||
| 106 | |||
| 107 | ;; mm-archive.el ends here | ||
diff --git a/lisp/gnus/tests/gnustest-nntp.el b/lisp/gnus/tests/gnustest-nntp.el new file mode 100644 index 00000000000..1ce972520d3 --- /dev/null +++ b/lisp/gnus/tests/gnustest-nntp.el | |||
| @@ -0,0 +1,94 @@ | |||
| 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 | ) | ||
diff --git a/lisp/gnus/tests/gnustest-registry.el b/lisp/gnus/tests/gnustest-registry.el new file mode 100644 index 00000000000..512fab49939 --- /dev/null +++ b/lisp/gnus/tests/gnustest-registry.el | |||
| @@ -0,0 +1,216 @@ | |||
| 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) | ||