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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551
|
;;; mh-utils-tests.el --- tests for mh-utils.el -*- lexical-binding: t -*-
;; Copyright (C) 2021-2025 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:
;; This test suite runs tests that use and depend on MH programs
;; installed on the system.
;; When running such tests, MH-E can use a particular MH variant
;; installed on the system, or it can use the mocks provided here.
;; (Setup is done by the `with-mh-test-env' macro.)
;; By setting environment variable TEST_MH_PATH, you can select which of
;; the installed MH variants to use, or ignore them all and use mocks.
;; See also the script test-all-mh-variants.sh in this directory.
;; 1. To run these tests against the default MH variant installed on
;; this system:
;; cd ../.. && make lisp/mh-e/mh-utils-tests
;; 2. To run these tests against an MH variant installed in a
;; specific directory, set TEST_MH_PATH, as in this example:
;; cd ../.. && make lisp/mh-e/mh-utils-tests TEST_MH_PATH=/usr/local/nmh/bin
;; 3. To search for and run these tests against all MH variants
;; installed on this system:
;; ./test-all-mh-variants.sh
;; Setting the environment variable TEST_MH_DEBUG or the Lisp variable
;; mh-test-utils-debug-mocks logs access to the file system during the test.
;;; Code:
(require 'ert)
(require 'mh-utils)
(eval-when-compile
(require 'cl-lib)
(require 'subr-x))
(ert-deftest mh-quote-pick-expr ()
"Test `mh-quote-pick-expr'."
(should (equal nil (mh-quote-pick-expr nil)))
(should (equal '() (mh-quote-pick-expr '())))
(should (equal '("foo") (mh-quote-pick-expr '("foo"))))
(should (equal '("^\\[foo]?\\*+\\.\\$")
(mh-quote-pick-expr '("^[foo]?*+.$"))))
(should (equal '("^\\[foo]?\\*+\\.\\$" "bar" "baz\\$")
(mh-quote-pick-expr '("^[foo]?*+.$" "bar" "baz$")))))
(ert-deftest mh-normalize-folder-name ()
"Test `mh-normalize-folder-name'."
(should (equal nil (mh-normalize-folder-name nil)))
(should (equal "+" (mh-normalize-folder-name "")))
(should (equal "" (mh-normalize-folder-name "" t)))
(should (equal nil (mh-normalize-folder-name "" nil nil t)))
(should (equal nil (mh-normalize-folder-name "+" nil nil t)))
(should (equal nil (mh-normalize-folder-name "+" t t t)))
(should (equal "+inbox" (mh-normalize-folder-name "inbox")))
(should (equal "+inbox" (mh-normalize-folder-name "+inbox")))
(should (equal "+inbox" (mh-normalize-folder-name "+inbox/")))
(should (equal "+inbox/" (mh-normalize-folder-name "+inbox/" t t t)))
(should (equal "+inbox/" (mh-normalize-folder-name "+inbox/" nil t)))
(should (equal "+news" (mh-normalize-folder-name "+inbox////../news")))
(should (equal "+news" (mh-normalize-folder-name "+inbox////../news/")))
(should (equal "+news/"
(mh-normalize-folder-name "+inbox////../news/" nil t)))
(should (equal "+inbox/news" (mh-normalize-folder-name "+inbox////./news"))))
(ert-deftest mh-sub-folders-parse-no-folder ()
"Test `mh-sub-folders-parse' with no starting folder."
(let (others-position)
(with-temp-buffer
(insert "lines without has-string are ignored\n")
(insert "onespace has no messages.\n")
(insert "twospace has no messages.\n")
(insert " precedingblanks has no messages.\n")
(insert ".leadingdot has no messages.\n")
(insert "#leadinghash has no messages.\n")
(insert ",leadingcomma has no messages.\n")
(insert "withothers has no messages ; (others)")
(setq others-position (point))
(insert ".\n")
(insert "curf has no messages.\n")
(insert "curf+ has 123 messages.\n")
(insert "curf2+ has 17 messages.\n")
(insert "\ntotal after blank line is ignored has no messages.\n")
(should (equal
(mh-sub-folders-parse nil "curf+")
(list '("onespace") '("twospace") '("precedingblanks")
(cons "withothers" others-position)
'("curf") '("curf") '("curf2+")))))))
(ert-deftest mh-sub-folders-parse-relative-folder ()
"Test `mh-sub-folders-parse' with folder."
(let (others-position)
(with-temp-buffer
(insert "testf+ has no messages.\n")
(insert "testf/sub1 has no messages.\n")
(insert "testf/sub2 has no messages ; (others)")
(setq others-position (point))
(insert ".\n")
(should (equal
(mh-sub-folders-parse "+testf" "testf+")
(list '("sub1") (cons "sub2" others-position)))))))
(ert-deftest mh-sub-folders-parse-root-folder ()
"Test `mh-sub-folders-parse' with root folder."
(with-temp-buffer
(insert "/+ has no messages.\n")
(insert "/ has no messages.\n")
(insert "//nmh-style has no messages.\n")
(insert "/mu-style has no messages.\n")
(should (equal
(mh-sub-folders-parse "+/" "inbox+")
'(("") ("nmh-style") ("mu-style"))))))
;; Folder names that are used by the following tests.
(defvar mh-test-rel-folder "rela-folder")
(defvar mh-test-abs-folder "/abso-folder")
(defvar mh-test-no-such-folder "/testdir/none" "A folder that does not exist.")
(defvar mh-test-utils-variants nil
"The value of `mh-variants' used for these tests.
This variable allows setting `mh-variants' to a limited set for targeted
testing. Its value can be different from the normal value when
environment variable TEST_MH_PATH is set. By remembering the value, we
can log the choice only once, which makes the batch log easier to read.")
(defvar mh-test-variant-logged-already nil
"Whether `with-mh-test-env' has written the MH variant to the log.")
(defvar mh-test-utils-debug-mocks (> (length (getenv "TEST_MH_DEBUG")) 0)
"Whether to log detailed behavior of mock functions.")
(defvar mh-test-call-process-real (symbol-function 'call-process))
(defvar mh-test-file-directory-p-real (symbol-function 'file-directory-p))
;;; The macro with-mh-test-env wraps tests that touch the file system
;;; and/or run programs.
(defmacro with-mh-test-env (&rest body)
"Evaluate BODY with a test mail environment.
Functions that touch the file system or run MH programs are either
mocked out or pointed at a test tree. Uses `mh-test-utils-setup' to
select which."
(declare (indent 0) (debug t))
`(cl-letf ((temp-home-dir nil)
;; make local bindings for things we will modify for test env
(mh-user-path)
(mh-test-abs-folder)
((symbol-function 'call-process))
((symbol-function 'file-directory-p))
;; the test always gets its own sub-folders cache
(mh-sub-folders-cache (make-hash-table :test #'equal))
;; Allow envvar TEST_MH_PATH to control mh-variants.
(mh-variants mh-test-utils-variants)
;; remember the original value
(original-mh-test-variant-logged mh-test-variant-logged-already)
(original-mh-path mh-path)
(original-mh-sys-path mh-sys-path)
(original-exec-path exec-path)
(original-mh-variant-in-use mh-variant-in-use)
(original-mh-progs mh-progs)
(original-mh-lib mh-lib)
(original-mh-lib-progs mh-lib-progs)
(original-mh-envvar (getenv "MH")))
(unwind-protect
(progn
(setq temp-home-dir (mh-test-utils-setup))
,@body)
(unless noninteractive
;; If interactive, forget that we logged the variant and
;; restore any changes TEST_MH_PATH made.
(setq mh-test-variant-logged-already original-mh-test-variant-logged
mh-path original-mh-path
mh-sys-path original-mh-sys-path
exec-path original-exec-path
mh-variant-in-use original-mh-variant-in-use
mh-progs original-mh-progs
mh-lib original-mh-lib
mh-lib-progs original-mh-lib-progs))
(if temp-home-dir (delete-directory temp-home-dir t))
(setenv "MH" original-mh-envvar))))
(defun mh-test-utils-setup ()
"Set dynamically bound variables needed by mock and/or variants.
Call `mh-variant-set' to look through the directories named by
environment variable `TEST_MH_PATH' (default: `mh-path' and `mh-sys-path')
to find the MH variant to use, if any.
Return the name of the root of the created directory tree, if any."
(when (getenv "TEST_MH_PATH")
;; force mh-variants to use only TEST_MH_PATH
(setq mh-path (split-string (getenv "TEST_MH_PATH") path-separator t)
mh-sys-path nil
exec-path '("/bin" "/usr/bin")))
(unless mh-test-variant-logged-already
(mh-variant-set mh-variant)
(setq mh-test-utils-variants mh-variants)
(setq mh-test-variant-logged-already t))
(when (native-comp-available-p)
;; As `call-process'' and `file-directory-p' will be redefined, the
;; native compiler will invoke `call-process' to compile the
;; respective trampolines. To avoid interference with the
;; `call-process' mocking, we build these ahead of time.
(mapc #'comp-subr-trampoline-install '(call-process file-directory-p)))
(if mh-variant-in-use
(mh-test-utils-setup-with-variant)
(mh-test-utils-setup-with-mocks)))
(defun mh-test-utils-setup-with-mocks ()
"Set dynamically bound variables so that MH programs are mocked out.
The tests use this method if no configured MH variant is found."
(setq mh-user-path "/testdir/Mail/")
(mh-populate-sub-folders-cache "+")
(mh-populate-sub-folders-cache "+rela-folder")
(mh-populate-sub-folders-cache "+rela-folder/bar")
(mh-populate-sub-folders-cache "+rela-folder/foo")
(mh-populate-sub-folders-cache "+rela-folder/food")
(fset 'call-process #'mh-test-utils-mock-call-process)
(fset 'file-directory-p #'mh-test-utils-mock-file-directory-p)
;; no temp directory created
nil)
(defun mh-test-utils-mock-call-process (program
&optional _infile _destination _display
&rest args)
"A mocked version of `call-process' that calls no processes."
(let ((argument-responses
;; assoc list of program arguments and lines to output.
'((("folder" "-fast") . ("rela-folder"))
(("folders" "-noheader" "-norecurse" "-nototal") .
("rela-folder has no messages."))
(("folders" "-noheader" "-norecurse" "-nototal" "+rela-folder") .
("rela-folder+ has no messages."
"rela-folder/bar has no messages."
"rela-folder/foo has no messages."
"rela-folder/food has no messages."))
(("folders" "-noheader" "-norecurse" "-nototal" "+rela-folder/foo") .
("rela-folder/foo+ has no messages."))
(("folders" "-noheader" "-norecurse" "-nototal" "+") .
("+ has no messages."))
(("folders" "-noheader" "-norecurse" "-nototal" "+/abso-folder") .
("/abso-folder+ has no messages."
"/abso-folder/bar has no messages."
"/abso-folder/foo has no messages."
"/abso-folder/food has no messages."))
(("folders" "-noheader" "-norecurse" "-nototal" "+/") .
("/+ has no messages ; (others)."
"/abso-folder has no messages ; (others)."
"/tmp has no messages ; (others)."))
))
(arglist (cons (file-name-base program) args)))
(let ((response-list-cons (assoc arglist argument-responses)))
(cond (response-list-cons
(let ((response-list (cdr response-list-cons)))
(when mh-test-utils-debug-mocks
(message "call-process mock arglist %s" arglist)
(message " -> response %S" response-list))
(while response-list
(insert (car response-list) "\n")
(setq response-list (cdr response-list))))
0)
(t
(message "call-process mock unexpected arglist %s" arglist)
1)))))
(defun mh-test-utils-mock-file-directory-p (filename)
"A mocked version of `file-directory-p' that does not access the file system."
(let ((directories '("" "/" "/tmp" "/abso-folder" "/abso-folder/foo"
"/testdir/Mail" "/testdir/Mail/rela-folder"
"/testdir/Mail/rela-folder/foo"
"rela-folder" "rela-folder/foo"))
(non-directories '("/abso-folder/fo" "rela-folder/fo"
"/testdir/Mail/rela-folder/fo"
"/testdir/Mail/nosuchfolder"
"/nosuchfolder" "nosuchfolder")))
(cond ((member (directory-file-name filename) directories)
(when mh-test-utils-debug-mocks
(message "file-directory-p mock: %S -> t" filename))
t)
((member (directory-file-name filename) non-directories)
(when mh-test-utils-debug-mocks
(message "file-directory-p mock: %S -> nil" filename))
nil)
(t
(message "file-directory-p mock unexpected filename: %S" filename)
nil))))
(defun mh-test-utils-setup-with-variant ()
"Create a temporary directory structure for actual MH programs to read.
Return the name of the root of the created directory tree.
Set dynamically bound variables so that MH programs may log.
The tests use this method if a configured MH variant is found."
(let* ((temp-home-dir
(make-temp-file "emacs-mh-e-unit-test-" t))
(profile (expand-file-name
".mh_profile" temp-home-dir))
(mail-dir (expand-file-name "Mail" temp-home-dir))
(rela-folder (expand-file-name
"rela-folder" mail-dir))
(abso-folder (expand-file-name
"abso-folder" temp-home-dir)))
(with-temp-file profile
(insert "Path: " mail-dir "\n" "Welcome: disable\n"))
(setenv "MH" profile)
(make-directory (expand-file-name "bar" rela-folder) t)
(make-directory (expand-file-name "foo" rela-folder) t)
(make-directory (expand-file-name "food" rela-folder) t)
(setq mh-user-path (file-name-as-directory mail-dir))
(make-directory (expand-file-name "bar" abso-folder) t)
(make-directory (expand-file-name "foo" abso-folder) t)
(make-directory (expand-file-name "food" abso-folder) t)
(setq mh-test-abs-folder abso-folder)
(fset 'call-process #'mh-test-utils-log-call-process)
(fset 'file-directory-p #'mh-test-utils-log-file-directory-p)
temp-home-dir))
(defun mh-test-utils-log-call-process (program
&optional infile destination display
&rest args)
"A wrapper around `call-process' that can log the program args and output.
Both args and output are written with `message' if `mh-test-utils-debug-mocks'
is non-nil."
(let (process-output)
(when mh-test-utils-debug-mocks
(message "call-process arglist %s" (cons program args)))
(with-temp-buffer
(apply mh-test-call-process-real program infile destination display args)
(setq process-output (buffer-string)))
(when mh-test-utils-debug-mocks
(message " -> response:\n%s" process-output))
(insert process-output)))
(defun mh-test-utils-log-file-directory-p (filename)
"A wrapper around `file-directory-p' that can log calls.
Both FILENAME and the return value are written with `message'
if `mh-test-utils-debug-mocks' is non-nil."
(let ((result (funcall mh-test-file-directory-p-real filename)))
(when mh-test-utils-debug-mocks
(message "file-directory-p: %S -> %s" filename result))
result))
(defun mh-test-variant-handles-plus-slash (variant)
"Returns non-nil if this MH variant handles \"folders +/\".
Mailutils 3.5, 3.7, and 3.13 are known not to."
(cond ((not (stringp variant))) ;our mock handles it
((string-search "GNU Mailutils" variant)
(let ((mu-version (string-remove-prefix "GNU Mailutils " variant)))
(version<= "3.13.91" mu-version)))
(t))) ;no other known failures
(ert-deftest mh-sub-folders-actual ()
"Test `mh-sub-folders-actual'."
;; Note that mh-sub-folders-actual expects the folder to have
;; already been normalized with
;; (mh-normalize-folder-name folder nil nil t)
(with-mh-test-env
(should (member
mh-test-rel-folder
(mapcar (lambda (x) (car x)) (mh-sub-folders-actual nil))))
;; Empty string and "+" not tested since mh-normalize-folder-name
;; would change them to nil.
(should (member "foo"
(mapcar (lambda (x) (car x))
(mh-sub-folders-actual
(format "+%s" mh-test-rel-folder)))))
;; Folder with trailing slash not tested since
;; mh-normalize-folder-name would strip it.
(should (equal
nil
(mh-sub-folders-actual (format "+%s/foo" mh-test-rel-folder))))
(should (equal
(list (list "bar") (list "foo") (list "food"))
(mh-sub-folders-actual (format "+%s" mh-test-abs-folder))))
(when (mh-test-variant-handles-plus-slash mh-variant-in-use)
(should (member "tmp" (mapcar (lambda (x) (car x))
(mh-sub-folders-actual "+/")))))
;; FIXME: mh-sub-folders-actual doesn't (yet) expect to be given a
;; nonexistent folder.
;; (should (equal nil
;; (mh-sub-folders-actual "+nosuchfolder")))
;; (should (equal nil
;; (mh-sub-folders-actual "+/nosuchfolder")))
))
(ert-deftest mh-sub-folders ()
"Test `mh-sub-folders'."
(with-mh-test-env
(should (member mh-test-rel-folder
(mapcar (lambda (x) (car x)) (mh-sub-folders nil))))
(should (member mh-test-rel-folder
(mapcar (lambda (x) (car x)) (mh-sub-folders ""))))
(should-not (member mh-test-no-such-folder
(mapcar (lambda (x) (car x)) (mh-sub-folders "+"))))
(should (equal (list (list "bar") (list "foo") (list "food"))
(mh-sub-folders (format "+%s" mh-test-rel-folder))))
(should (equal (list (list "bar") (list "foo") (list "food"))
(mh-sub-folders (format "+%s/" mh-test-rel-folder))))
(should (equal nil
(mh-sub-folders (format "+%s/foo/" mh-test-rel-folder))))
(should (equal nil
(mh-sub-folders (format "+%s/foo" mh-test-rel-folder))))
(should (equal (list (list "bar") (list "foo") (list "food"))
(mh-sub-folders (format "+%s" mh-test-abs-folder))))
(when (mh-test-variant-handles-plus-slash mh-variant-in-use)
(should (member "tmp"
(mapcar (lambda (x) (car x)) (mh-sub-folders "+/")))))
;; FIXME: mh-sub-folders doesn't (yet) expect to be given a
;; nonexistent folder.
;; (should (equal nil
;; (mh-sub-folders "+nosuchfolder")))
;; (should (equal nil
;; (mh-sub-folders "+/nosuchfolder")))
))
(defmacro mh-test-folder-completion-1 (name
nil-expected t-expected lambda-expected)
"Helper for testing `mh-folder-completion-function'.
Ask for completion on NAME three times, with three different
values for the FLAG argument of `mh-folder-completion-function'.
NIL-EXPECTED is the expected value with FLAG nil.
T-EXPECTED is the expected value with FLAG t.
LAMBDA-EXPECTED is the expected value with FLAG lambda."
(declare (debug t))
`(with-mh-test-env
(mh-test-folder-completion-2 ,nil-expected ;case "a"
(mh-folder-completion-function ,name nil nil))
(mh-test-folder-completion-2 ,t-expected ;case "b"
(mh-folder-completion-function ,name nil t))
(mh-test-folder-completion-2 ,lambda-expected ;case "c"
(mh-folder-completion-function ,name nil
'lambda))))
(defmacro mh-test-folder-completion-2 (expected actual)
"Inner helper for testing `mh-folder-completion-function'.
ACTUAL should evaluate to either EXPECTED or to a list containing EXPECTED.
ACTUAL may be evaluated twice, but this gives a clearer error on failure,
and the `should' macro requires idempotent evaluation anyway."
(declare (debug t))
`(if (and (not (consp ,expected)) (consp ,actual))
(should (member ,expected ,actual))
(should (equal ,expected ,actual))))
(ert-deftest mh-folder-completion-function-02-empty ()
"Test `mh-folder-completion-function' with empty name."
(mh-test-folder-completion-1 "" "+" (format "%s/" mh-test-rel-folder) nil))
(ert-deftest mh-folder-completion-function-03-plus ()
"Test `mh-folder-completion-function' with `+'."
(mh-test-folder-completion-1 "+" "+" (format "%s/" mh-test-rel-folder) nil))
(ert-deftest mh-folder-completion-function-04-rel-folder ()
"Test `mh-folder-completion-function' with `+rela-folder'."
(mh-test-folder-completion-1 (format "+%s" mh-test-rel-folder)
(format "+%s/" mh-test-rel-folder)
(list (format "%s/" mh-test-rel-folder))
t))
(ert-deftest mh-folder-completion-function-05-rel-folder-slash ()
"Test `mh-folder-completion-function' with `+rela-folder/'."
(mh-test-folder-completion-1 (format "+%s/" mh-test-rel-folder)
(format "+%s/" mh-test-rel-folder)
(list "bar" "foo" "food")
t))
(ert-deftest mh-folder-completion-function-06-rel-folder-slash-foo ()
"Test `mh-folder-completion-function' with `+rela-folder/foo'."
(mh-test-folder-completion-1 (format "+%s/foo" mh-test-rel-folder)
(format "+%s/foo" mh-test-rel-folder)
(list "foo" "food")
t)
(with-mh-test-env
(should (equal nil
(mh-folder-completion-function
(format "+%s/fo" mh-test-rel-folder) nil 'lambda)))))
(ert-deftest mh-folder-completion-function-07-rel-folder-slash-foo-slash ()
"Test `mh-folder-completion-function' with `+rela-folder/foo/'."
(mh-test-folder-completion-1 (format "+%s/foo/" mh-test-rel-folder)
nil
nil
t))
(ert-deftest mh-folder-completion-function-08-plus-slash ()
"Test `mh-folder-completion-function' with `+/'."
(with-mh-test-env
(skip-unless (mh-test-variant-handles-plus-slash mh-variant-in-use)))
(mh-test-folder-completion-1 "+/" "+/" "tmp/" t)
;; case "bb"
(with-mh-test-env
(should (equal nil
(member (format "+%s/" mh-test-rel-folder)
(mh-folder-completion-function "+/" nil t))))))
(ert-deftest mh-folder-completion-function-09-plus-slash-tmp ()
"Test `mh-folder-completion-function' with `+/tmp'."
(with-mh-test-env
(skip-unless (mh-test-variant-handles-plus-slash mh-variant-in-use)))
(mh-test-folder-completion-1 "+/tmp" "+/tmp/" "tmp/" t))
(ert-deftest mh-folder-completion-function-10-plus-slash-abs-folder ()
"Test `mh-folder-completion-function' with `+/abso-folder'."
(mh-test-folder-completion-1 (format "+%s/" mh-test-abs-folder)
(format "+%s/" mh-test-abs-folder)
(list "bar" "foo" "food")
t))
(ert-deftest mh-folder-completion-function-11-plus-slash-abs-folder-slash-foo ()
"Test `mh-folder-completion-function' with `+/abso-folder/foo'."
(mh-test-folder-completion-1 (format "+%s/foo" mh-test-abs-folder)
(format "+%s/foo" mh-test-abs-folder)
(list "foo" "food")
t)
(with-mh-test-env
(should (equal nil
(mh-folder-completion-function
(format "+%s/fo" mh-test-abs-folder) nil 'lambda)))))
(ert-deftest mh-folder-completion-function-12-plus-nosuchfolder ()
"Test `mh-folder-completion-function' with `+nosuchfolder'."
(mh-test-folder-completion-1 "+nosuchfolder" nil nil nil))
(ert-deftest mh-folder-completion-function-13-plus-slash-nosuchfolder ()
"Test `mh-folder-completion-function' with `+/nosuchfolder'."
(mh-test-folder-completion-1 "+/nosuchfolder" nil nil nil))
;;; mh-utils-tests.el ends here
|