1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
| | ;;; gnus-tests.el --- Wrapper for the Gnus tests -*- lexical-binding:t -*-
;; Copyright (C) 2011-2022 Free Software Foundation, Inc.
;; Author: Teodor Zlatanov <tzz@lifelogs.com>
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; This file should contain nothing but requires for all the Gnus
;; tests that are not standalone.
;;; Code:
(require 'cl-macs)
(require 'message)
(require 'gnus)
(require 'gnus-start)
(require 'gnus-group)
(require 'nsm)
(defconst gnus-tests-load-file-name (or load-file-name
(buffer-file-name)))
(defmacro gnus-tests-let-customs (bindings &rest forms)
(declare (indent defun))
`(progn
(funcall #'custom-set-variables
,@(mapcar (apply-partially #'list 'quote) bindings))
,@forms))
(cl-defmacro gnus-tests-doit (&rest
body
&key
(select-method)
(customs)
&allow-other-keys
&aux
(body
(cl-loop until (not (keywordp (car body)))
do (setq body (nthcdr 2 body))
finally return body)))
(declare (indent defun))
`(let* ((parent-dir (file-name-directory gnus-tests-load-file-name))
(default-directory (file-name-as-directory (concat parent-dir "gnus-tests")))
(user-emacs-directory default-directory))
(unless (file-exists-p default-directory)
(make-directory default-directory))
(gnus-tests-let-customs
((gnus-verbose 8)
(gnus-home-directory default-directory)
(gnus-use-dribble-file nil)
(network-security-level (quote low))
(gnus-interactive-exit (quote quiet))
,@(when select-method (list `(gnus-select-method ',select-method)))
(message-directory (concat gnus-home-directory "Mail"))
(mail-source-directory (concat gnus-home-directory "Mail"))
(mail-source-crash-box (concat gnus-home-directory ".whatev"))
(gnus-startup-file (nnheader-concat gnus-home-directory ".newsrc.eld"))
(gnus-init-file (nnheader-concat gnus-home-directory ".gnus"))
(gnus-directory (nnheader-concat gnus-home-directory "News/"))
,@customs)
(unwind-protect
(progn ,@body)
(cl-macrolet ((safe-delete
(x)
`(if (cl-search "gnus-tests/" ,x)
(delete-directory ,x t)
(error "Attempted delete of %s!" ,x))))
(safe-delete gnus-home-directory))))))
(ert-deftest gnus-test-basic-op ()
(gnus-tests-doit :select-method (nnfolder "")
(call-interactively #'gnus)
(call-interactively #'gnus-group-exit)))
(ert-deftest gnus-test-server-at-eob ()
"`gnus-server-read-server' looks to nearest nonempty line."
(gnus-tests-doit :select-method (nnfolder "")
(call-interactively #'gnus)
(call-interactively #'gnus-group-enter-server-mode)
(with-current-buffer gnus-server-buffer
(should-error (search-forward "foobar"))
(search-forward "nnfolder")
(goto-char (point-max))
(should (gnus-server-server-name))
(goto-char (point-min))
(should (gnus-server-server-name)))
(call-interactively #'gnus-group-exit)))
(provide 'gnus-tests)
;;; gnus-tests.el ends here
|