unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
blob c65c2ce88083bf4ffe06fdd75e19a79644411070 4609 bytes (raw)
name: test/lisp/gnus/gnus-tests.el 	 # note: path name is non-authoritative(*)

  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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 
;;; gnus-tests.el --- Wrapper for the Gnus tests  -*- lexical-binding:t -*-

;; Copyright (C) 2011-2021 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 '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))
  `(let (,@(mapcar #'car bindings))
     (ignore ,@(mapcar #'car bindings))
     (funcall #'custom-set-variables
              ,@(mapcar (apply-partially #'list 'quote) bindings))
     ,@forms))

(cl-defmacro gnus-tests-doit (&rest
                              body
                              &key
                              (select-methods '(default-value 'gnus-select-methods))
                              (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-save-dot-newsrc nil)
        (gnus-home-directory default-directory)
        (gnus-use-dribble-file nil)
        (network-security-level (quote low))
        (gnus-interactive-exit (quote quiet))
        (gnus-select-methods ,select-methods)
        (message-directory (concat default-directory "Mail"))
        (mail-source-directory message-directory)
        (mail-source-crash-box (concat default-directory ".whatev"))
        (gnus-newsrc-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 default-directory))))))

(ert-deftest gnus-test-clean-room ()
  (gnus-tests-doit
    (should (equal gnus-select-methods (default-value 'gnus-select-methods)))
    (should-not gnus-save-dot-newsrc))
  (should gnus-save-dot-newsrc))

(ert-deftest gnus-test-select-methods ()
  (gnus-tests-doit :select-methods (quote ((nnfolder "")))
    (should (equal gnus-select-methods (quote ((nnfolder "")))))
    (should (equal gnus-select-method (quote (nnfolder ""))))
    (should-not gnus-secondary-select-methods)))

(ert-deftest gnus-test-be-nicer-to-noobs ()
  "Between the time Linux entered the home and the time I wrote this test,
the innocent user trying `M-x gnus` would be rebuffed with hostility."
  (gnus-tests-doit
    (with-current-buffer "*Messages*"
      (let ((inhibit-read-only t))
        (erase-buffer)))
    (let ((inhibit-message t))
      (call-interactively #'gnus))
    (with-current-buffer "*Messages*"
      (save-excursion
        (goto-char (point-min))
        (should-error (re-search-forward "failed"))))))

(ert-deftest gnus-test-basic-op ()
  (gnus-tests-doit :select-methods (quote ((nnfolder "")))
    (call-interactively #'gnus)))

(provide 'gnus-tests)
;;; gnus-tests.el ends here

debug log:

solving c65c2ce880 ...
found c65c2ce880 in https://yhetil.org/emacs-bugs/87fsxhwv47.fsf@dick/
found 6602e67a34 in https://git.savannah.gnu.org/cgit/emacs.git
preparing index
index prepared:
100644 6602e67a347f65c1a4decf699f090b4ea8966c2e	test/lisp/gnus/gnus-tests.el

applying [1/1] https://yhetil.org/emacs-bugs/87fsxhwv47.fsf@dick/
diff --git a/test/lisp/gnus/gnus-tests.el b/test/lisp/gnus/gnus-tests.el
index 6602e67a34..c65c2ce880 100644

Checking patch test/lisp/gnus/gnus-tests.el...
Applied patch test/lisp/gnus/gnus-tests.el cleanly.

index at:
100644 c65c2ce88083bf4ffe06fdd75e19a79644411070	test/lisp/gnus/gnus-tests.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).