unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
blob c034f02c4f74660fe93c2ec08116681d42d702d1 4213 bytes (raw)
name: test/lisp/pcomplete-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
 
;;; pcomplete-tests.el --- Tests for pcomplete.el  -*- lexical-binding: t -*-

;; Copyright (C) 2022 Free Software Foundation, Inc.

;; 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:

;;; Code:

(require 'ert)
(require 'pcomplete)

(ert-deftest pcomplete-test-parse-help-gpg ()
  (cl-letf ((pcomplete-parse-help (make-hash-table :test #'equal))
            ((symbol-function 'call-process-shell-command)
             (lambda (&rest _) (insert "\
gpg (GnuPG) 2.3.7

Commands:

 -s, --sign                         make a signature
     --clear-sign                   make a clear text signature
 -b, --detach-sign                  make a detached signature
     --tofu-policy VALUE            set the TOFU policy for a key

Options to specify keys:
 -r, --recipient USER-ID            encrypt for USER-ID
 -u, --local-user USER-ID           use USER-ID to sign or decrypt

(See the man page for a complete listing of all commands and options)

Examples:

 -se -r Bob [file]          sign and encrypt for user Bob
 --clear-sign [file]        make a clear text signature
"))))
    (should
     (equal-including-properties
      (pcomplete-parse-help "gpg --help" :narrow-end "^ -se")
      '(#("-s" 0 1 (pcomplete-help "make a signature"))
        #("--sign" 0 1 (pcomplete-help "make a signature"))
        #("--clear-sign" 0 1 (pcomplete-help "make a clear text signature"))
        #("-b" 0 1 (pcomplete-help "make a detached signature"))
        #("--detach-sign" 0 1 (pcomplete-help "make a detached signature"))
        #("--tofu-policy" 0 1
          (pcomplete-help "set the TOFU policy for a key" pcomplete-annotation " VALUE"))
        #("-r" 0 1 (pcomplete-help "encrypt for USER-ID"))
        #("--recipient" 0 1
          (pcomplete-help "encrypt for USER-ID" pcomplete-annotation " USER-ID"))
        #("-u" 0 1
          (pcomplete-help "use USER-ID to sign or decrypt"))
        #("--local-user" 0 1
          (pcomplete-help "use USER-ID to sign or decrypt" pcomplete-annotation " USER-ID")))))))

(ert-deftest pcomplete-test-parse-help-git ()
  (cl-letf ((pcomplete-parse-help (make-hash-table :test #'equal))
            ((symbol-function 'call-process-shell-command)
             (lambda (&rest _) (insert "\
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <command> [<args>]
"))))
    (should
     (equal-including-properties
      (pcomplete-parse-help "git help"
                             :margin "\\(\\[\\)-"
                             :separator " | "
                             :description "\\`")
      '("-v" "--version" "-h" "--help"
        #("-C" 0 1 (pcomplete-annotation " <path>"))
        #("-c" 0 1 (pcomplete-annotation " <name>"))
        #("--exec-path" 0 1 (pcomplete-annotation "[=<path>]"))
        "--html-path" "--man-path" "--info-path"
        "-p" "--paginate" "-P" "--no-pager"
        "--no-replace-objects" "--bare"
        #("--git-dir=" 0 1 (pcomplete-annotation "<path>"))
        #("--work-tree=" 0 1 (pcomplete-annotation "<path>"))
        #("--namespace=" 0 1 (pcomplete-annotation "<name>"))
        #("--super-prefix=" 0 1 (pcomplete-annotation "<path>"))
        #("--config-env=" 0 1 (pcomplete-annotation "<name>")))))))

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

debug log:

solving c034f02c4f ...
found c034f02c4f in https://yhetil.org/emacs-bugs/87zgfagqfs.fsf@gmail.com/

applying [1/1] https://yhetil.org/emacs-bugs/87zgfagqfs.fsf@gmail.com/
diff --git a/test/lisp/pcomplete-tests.el b/test/lisp/pcomplete-tests.el
new file mode 100644
index 0000000000..c034f02c4f

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

index at:
100644 c034f02c4f74660fe93c2ec08116681d42d702d1	test/lisp/pcomplete-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).