aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStephen Gildea2021-11-24 07:27:18 -0800
committerStephen Gildea2021-11-24 07:27:18 -0800
commitf1fcd321ff40315442cd77084c444585948bea85 (patch)
tree1a2f6393f0c30abbc372d59d5fbe5dd2d4fc26d0 /test
parent7dfa758fef58dbfcd00baaea374260d5d3510b7f (diff)
downloademacs-f1fcd321ff40315442cd77084c444585948bea85.tar.gz
emacs-f1fcd321ff40315442cd77084c444585948bea85.zip
mh-utils-tests: Add new tests of "folders +/"
* test/lisp/mh-e/mh-utils-tests.el (mh-sub-folders-actual, mh-sub-folders): Add new tests of "folders +/". Rewrite tests that were using 'assoc' to use 'member' instead, so that on failure, ERT logs the list of which the element was not a member, rather than the 'nil' returned by 'assoc'. (mh-test-variant-handles-plus-slash): Factor out new helper function. (mh-folder-completion-function-08-plus-slash) (mh-folder-completion-function-09-plus-slash-tmp): Use new helper function. * test/lisp/mh-e/test-all-mh-variants.sh: LD_LIBRARY_PATH unnecessary.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/mh-e/mh-utils-tests.el47
-rwxr-xr-xtest/lisp/mh-e/test-all-mh-variants.sh6
2 files changed, 31 insertions, 22 deletions
diff --git a/test/lisp/mh-e/mh-utils-tests.el b/test/lisp/mh-e/mh-utils-tests.el
index 0066c00b5b2..5f6accc6470 100644
--- a/test/lisp/mh-e/mh-utils-tests.el
+++ b/test/lisp/mh-e/mh-utils-tests.el
@@ -307,6 +307,14 @@ if `mh-test-utils-debug-mocks' is non-nil."
307 (message "file-directory-p: %S -> %s" filename result)) 307 (message "file-directory-p: %S -> %s" filename result))
308 result)) 308 result))
309 309
310(defun mh-test-variant-handles-plus-slash (variant)
311 "Returns non-nil if this MH variant handles \"folders +/\".
312Mailutils 3.5, 3.7, and 3.13 are known not to."
313 (cond ((not (stringp variant))) ;our mock handles it
314 ((string-search "GNU Mailutils" variant)
315 nil)
316 (t))) ;no other known failures
317
310 318
311(ert-deftest mh-sub-folders-actual () 319(ert-deftest mh-sub-folders-actual ()
312 "Test `mh-sub-folders-actual'." 320 "Test `mh-sub-folders-actual'."
@@ -314,14 +322,15 @@ if `mh-test-utils-debug-mocks' is non-nil."
314 ;; already been normalized with 322 ;; already been normalized with
315 ;; (mh-normalize-folder-name folder nil nil t) 323 ;; (mh-normalize-folder-name folder nil nil t)
316 (with-mh-test-env 324 (with-mh-test-env
317 (should (equal 325 (should (member
318 mh-test-rel-folder 326 mh-test-rel-folder
319 (car (assoc mh-test-rel-folder (mh-sub-folders-actual nil))))) 327 (mapcar (lambda (x) (car x)) (mh-sub-folders-actual nil))))
320 ;; Empty string and "+" not tested since mh-normalize-folder-name 328 ;; Empty string and "+" not tested since mh-normalize-folder-name
321 ;; would change them to nil. 329 ;; would change them to nil.
322 (should (equal "foo" 330 (should (member "foo"
323 (car (assoc "foo" (mh-sub-folders-actual 331 (mapcar (lambda (x) (car x))
324 (format "+%s" mh-test-rel-folder)))))) 332 (mh-sub-folders-actual
333 (format "+%s" mh-test-rel-folder)))))
325 ;; Folder with trailing slash not tested since 334 ;; Folder with trailing slash not tested since
326 ;; mh-normalize-folder-name would strip it. 335 ;; mh-normalize-folder-name would strip it.
327 (should (equal 336 (should (equal
@@ -332,6 +341,10 @@ if `mh-test-utils-debug-mocks' is non-nil."
332 (list (list "bar") (list "foo") (list "food")) 341 (list (list "bar") (list "foo") (list "food"))
333 (mh-sub-folders-actual (format "+%s" mh-test-abs-folder)))) 342 (mh-sub-folders-actual (format "+%s" mh-test-abs-folder))))
334 343
344 (when (mh-test-variant-handles-plus-slash mh-variant-in-use)
345 (should (member "tmp" (mapcar (lambda (x) (car x))
346 (mh-sub-folders-actual "+/")))))
347
335 ;; FIXME: mh-sub-folders-actual doesn't (yet) expect to be given a 348 ;; FIXME: mh-sub-folders-actual doesn't (yet) expect to be given a
336 ;; nonexistent folder. 349 ;; nonexistent folder.
337 ;; (should (equal nil 350 ;; (should (equal nil
@@ -343,13 +356,12 @@ if `mh-test-utils-debug-mocks' is non-nil."
343(ert-deftest mh-sub-folders () 356(ert-deftest mh-sub-folders ()
344 "Test `mh-sub-folders'." 357 "Test `mh-sub-folders'."
345 (with-mh-test-env 358 (with-mh-test-env
346 (should (equal mh-test-rel-folder 359 (should (member mh-test-rel-folder
347 (car (assoc mh-test-rel-folder (mh-sub-folders nil))))) 360 (mapcar (lambda (x) (car x)) (mh-sub-folders nil))))
348 (should (equal mh-test-rel-folder 361 (should (member mh-test-rel-folder
349 (car (assoc mh-test-rel-folder (mh-sub-folders ""))))) 362 (mapcar (lambda (x) (car x)) (mh-sub-folders ""))))
350 (should (equal nil 363 (should-not (member mh-test-no-such-folder
351 (car (assoc mh-test-no-such-folder (mh-sub-folders 364 (mapcar (lambda (x) (car x)) (mh-sub-folders "+"))))
352 "+")))))
353 (should (equal (list (list "bar") (list "foo") (list "food")) 365 (should (equal (list (list "bar") (list "foo") (list "food"))
354 (mh-sub-folders (format "+%s" mh-test-rel-folder)))) 366 (mh-sub-folders (format "+%s" mh-test-rel-folder))))
355 (should (equal (list (list "bar") (list "foo") (list "food")) 367 (should (equal (list (list "bar") (list "foo") (list "food"))
@@ -360,6 +372,9 @@ if `mh-test-utils-debug-mocks' is non-nil."
360 (mh-sub-folders (format "+%s/foo" mh-test-rel-folder)))) 372 (mh-sub-folders (format "+%s/foo" mh-test-rel-folder))))
361 (should (equal (list (list "bar") (list "foo") (list "food")) 373 (should (equal (list (list "bar") (list "foo") (list "food"))
362 (mh-sub-folders (format "+%s" mh-test-abs-folder)))) 374 (mh-sub-folders (format "+%s" mh-test-abs-folder))))
375 (when (mh-test-variant-handles-plus-slash mh-variant-in-use)
376 (should (member "tmp"
377 (mapcar (lambda (x) (car x)) (mh-sub-folders "+/")))))
363 378
364 ;; FIXME: mh-sub-folders doesn't (yet) expect to be given a 379 ;; FIXME: mh-sub-folders doesn't (yet) expect to be given a
365 ;; nonexistent folder. 380 ;; nonexistent folder.
@@ -441,10 +456,8 @@ and the `should' macro requires idempotent evaluation anyway."
441 456
442(ert-deftest mh-folder-completion-function-08-plus-slash () 457(ert-deftest mh-folder-completion-function-08-plus-slash ()
443 "Test `mh-folder-completion-function' with `+/'." 458 "Test `mh-folder-completion-function' with `+/'."
444 ;; This test fails with Mailutils 3.5, 3.7, and 3.13.
445 (with-mh-test-env 459 (with-mh-test-env
446 (skip-unless (not (and (stringp mh-variant-in-use) 460 (skip-unless (mh-test-variant-handles-plus-slash mh-variant-in-use)))
447 (string-search "GNU Mailutils" mh-variant-in-use)))))
448 (mh-test-folder-completion-1 "+/" "+/" "tmp/" t) 461 (mh-test-folder-completion-1 "+/" "+/" "tmp/" t)
449 ;; case "bb" 462 ;; case "bb"
450 (with-mh-test-env 463 (with-mh-test-env
@@ -454,10 +467,8 @@ and the `should' macro requires idempotent evaluation anyway."
454 467
455(ert-deftest mh-folder-completion-function-09-plus-slash-tmp () 468(ert-deftest mh-folder-completion-function-09-plus-slash-tmp ()
456 "Test `mh-folder-completion-function' with `+/tmp'." 469 "Test `mh-folder-completion-function' with `+/tmp'."
457 ;; This test fails with Mailutils 3.5, 3.7, and 3.13.
458 (with-mh-test-env 470 (with-mh-test-env
459 (skip-unless (not (and (stringp mh-variant-in-use) 471 (skip-unless (mh-test-variant-handles-plus-slash mh-variant-in-use)))
460 (string-search "GNU Mailutils" mh-variant-in-use)))))
461 (mh-test-folder-completion-1 "+/tmp" "+/tmp/" "tmp/" t)) 472 (mh-test-folder-completion-1 "+/tmp" "+/tmp/" "tmp/" t))
462 473
463(ert-deftest mh-folder-completion-function-10-plus-slash-abs-folder () 474(ert-deftest mh-folder-completion-function-10-plus-slash-abs-folder ()
diff --git a/test/lisp/mh-e/test-all-mh-variants.sh b/test/lisp/mh-e/test-all-mh-variants.sh
index e917d8155bc..eaee98fcf4d 100755
--- a/test/lisp/mh-e/test-all-mh-variants.sh
+++ b/test/lisp/mh-e/test-all-mh-variants.sh
@@ -79,12 +79,10 @@ for path in "${mh_sys_path[@]}"; do
79 continue 79 continue
80 fi 80 fi
81 fi 81 fi
82 echo "Testing with PATH $path" 82 echo "** Testing with PATH $path"
83 ((++tests_total)) 83 ((++tests_total))
84 # The LD_LIBRARY_PATH setting is needed
85 # to run locally installed Mailutils.
86 TEST_MH_PATH=$path TEST_MH_DEBUG=$debug \ 84 TEST_MH_PATH=$path TEST_MH_DEBUG=$debug \
87 LD_LIBRARY_PATH=/usr/local/lib HOME=/nonexistent \ 85 HOME=/nonexistent \
88 "${emacs[@]}" -l ert \ 86 "${emacs[@]}" -l ert \
89 --eval "(setq load-prefer-newer t)" \ 87 --eval "(setq load-prefer-newer t)" \
90 --eval "(load \"$PWD/test/lisp/mh-e/mh-utils-tests\" nil t)" \ 88 --eval "(load \"$PWD/test/lisp/mh-e/mh-utils-tests\" nil t)" \