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.
This commit is contained in:
parent
7dfa758fef
commit
f1fcd321ff
2 changed files with 31 additions and 22 deletions
|
@ -307,6 +307,14 @@ if `mh-test-utils-debug-mocks' is non-nil."
|
|||
(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)
|
||||
nil)
|
||||
(t))) ;no other known failures
|
||||
|
||||
|
||||
(ert-deftest mh-sub-folders-actual ()
|
||||
"Test `mh-sub-folders-actual'."
|
||||
|
@ -314,14 +322,15 @@ if `mh-test-utils-debug-mocks' is non-nil."
|
|||
;; already been normalized with
|
||||
;; (mh-normalize-folder-name folder nil nil t)
|
||||
(with-mh-test-env
|
||||
(should (equal
|
||||
(should (member
|
||||
mh-test-rel-folder
|
||||
(car (assoc mh-test-rel-folder (mh-sub-folders-actual nil)))))
|
||||
(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 (equal "foo"
|
||||
(car (assoc "foo" (mh-sub-folders-actual
|
||||
(format "+%s" mh-test-rel-folder))))))
|
||||
(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
|
||||
|
@ -332,6 +341,10 @@ if `mh-test-utils-debug-mocks' is non-nil."
|
|||
(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
|
||||
|
@ -343,13 +356,12 @@ if `mh-test-utils-debug-mocks' is non-nil."
|
|||
(ert-deftest mh-sub-folders ()
|
||||
"Test `mh-sub-folders'."
|
||||
(with-mh-test-env
|
||||
(should (equal mh-test-rel-folder
|
||||
(car (assoc mh-test-rel-folder (mh-sub-folders nil)))))
|
||||
(should (equal mh-test-rel-folder
|
||||
(car (assoc mh-test-rel-folder (mh-sub-folders "")))))
|
||||
(should (equal nil
|
||||
(car (assoc mh-test-no-such-folder (mh-sub-folders
|
||||
"+")))))
|
||||
(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"))
|
||||
|
@ -360,6 +372,9 @@ if `mh-test-utils-debug-mocks' is non-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.
|
||||
|
@ -441,10 +456,8 @@ and the `should' macro requires idempotent evaluation anyway."
|
|||
|
||||
(ert-deftest mh-folder-completion-function-08-plus-slash ()
|
||||
"Test `mh-folder-completion-function' with `+/'."
|
||||
;; This test fails with Mailutils 3.5, 3.7, and 3.13.
|
||||
(with-mh-test-env
|
||||
(skip-unless (not (and (stringp mh-variant-in-use)
|
||||
(string-search "GNU Mailutils" mh-variant-in-use)))))
|
||||
(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
|
||||
|
@ -454,10 +467,8 @@ and the `should' macro requires idempotent evaluation anyway."
|
|||
|
||||
(ert-deftest mh-folder-completion-function-09-plus-slash-tmp ()
|
||||
"Test `mh-folder-completion-function' with `+/tmp'."
|
||||
;; This test fails with Mailutils 3.5, 3.7, and 3.13.
|
||||
(with-mh-test-env
|
||||
(skip-unless (not (and (stringp mh-variant-in-use)
|
||||
(string-search "GNU Mailutils" mh-variant-in-use)))))
|
||||
(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 ()
|
||||
|
|
|
@ -79,12 +79,10 @@ for path in "${mh_sys_path[@]}"; do
|
|||
continue
|
||||
fi
|
||||
fi
|
||||
echo "Testing with PATH $path"
|
||||
echo "** Testing with PATH $path"
|
||||
((++tests_total))
|
||||
# The LD_LIBRARY_PATH setting is needed
|
||||
# to run locally installed Mailutils.
|
||||
TEST_MH_PATH=$path TEST_MH_DEBUG=$debug \
|
||||
LD_LIBRARY_PATH=/usr/local/lib HOME=/nonexistent \
|
||||
HOME=/nonexistent \
|
||||
"${emacs[@]}" -l ert \
|
||||
--eval "(setq load-prefer-newer t)" \
|
||||
--eval "(load \"$PWD/test/lisp/mh-e/mh-utils-tests\" nil t)" \
|
||||
|
|
Loading…
Add table
Reference in a new issue