mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-16 10:50:49 -08:00
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))
|
(message "file-directory-p: %S -> %s" filename result))
|
||||||
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 ()
|
(ert-deftest mh-sub-folders-actual ()
|
||||||
"Test `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
|
;; already been normalized with
|
||||||
;; (mh-normalize-folder-name folder nil nil t)
|
;; (mh-normalize-folder-name folder nil nil t)
|
||||||
(with-mh-test-env
|
(with-mh-test-env
|
||||||
(should (equal
|
(should (member
|
||||||
mh-test-rel-folder
|
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
|
;; Empty string and "+" not tested since mh-normalize-folder-name
|
||||||
;; would change them to nil.
|
;; would change them to nil.
|
||||||
(should (equal "foo"
|
(should (member "foo"
|
||||||
(car (assoc "foo" (mh-sub-folders-actual
|
(mapcar (lambda (x) (car x))
|
||||||
(format "+%s" mh-test-rel-folder))))))
|
(mh-sub-folders-actual
|
||||||
|
(format "+%s" mh-test-rel-folder)))))
|
||||||
;; Folder with trailing slash not tested since
|
;; Folder with trailing slash not tested since
|
||||||
;; mh-normalize-folder-name would strip it.
|
;; mh-normalize-folder-name would strip it.
|
||||||
(should (equal
|
(should (equal
|
||||||
|
|
@ -332,6 +341,10 @@ if `mh-test-utils-debug-mocks' is non-nil."
|
||||||
(list (list "bar") (list "foo") (list "food"))
|
(list (list "bar") (list "foo") (list "food"))
|
||||||
(mh-sub-folders-actual (format "+%s" mh-test-abs-folder))))
|
(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
|
;; FIXME: mh-sub-folders-actual doesn't (yet) expect to be given a
|
||||||
;; nonexistent folder.
|
;; nonexistent folder.
|
||||||
;; (should (equal nil
|
;; (should (equal nil
|
||||||
|
|
@ -343,13 +356,12 @@ if `mh-test-utils-debug-mocks' is non-nil."
|
||||||
(ert-deftest mh-sub-folders ()
|
(ert-deftest mh-sub-folders ()
|
||||||
"Test `mh-sub-folders'."
|
"Test `mh-sub-folders'."
|
||||||
(with-mh-test-env
|
(with-mh-test-env
|
||||||
(should (equal mh-test-rel-folder
|
(should (member mh-test-rel-folder
|
||||||
(car (assoc mh-test-rel-folder (mh-sub-folders nil)))))
|
(mapcar (lambda (x) (car x)) (mh-sub-folders nil))))
|
||||||
(should (equal mh-test-rel-folder
|
(should (member mh-test-rel-folder
|
||||||
(car (assoc mh-test-rel-folder (mh-sub-folders "")))))
|
(mapcar (lambda (x) (car x)) (mh-sub-folders ""))))
|
||||||
(should (equal nil
|
(should-not (member mh-test-no-such-folder
|
||||||
(car (assoc mh-test-no-such-folder (mh-sub-folders
|
(mapcar (lambda (x) (car x)) (mh-sub-folders "+"))))
|
||||||
"+")))))
|
|
||||||
(should (equal (list (list "bar") (list "foo") (list "food"))
|
(should (equal (list (list "bar") (list "foo") (list "food"))
|
||||||
(mh-sub-folders (format "+%s" mh-test-rel-folder))))
|
(mh-sub-folders (format "+%s" mh-test-rel-folder))))
|
||||||
(should (equal (list (list "bar") (list "foo") (list "food"))
|
(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))))
|
(mh-sub-folders (format "+%s/foo" mh-test-rel-folder))))
|
||||||
(should (equal (list (list "bar") (list "foo") (list "food"))
|
(should (equal (list (list "bar") (list "foo") (list "food"))
|
||||||
(mh-sub-folders (format "+%s" mh-test-abs-folder))))
|
(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
|
;; FIXME: mh-sub-folders doesn't (yet) expect to be given a
|
||||||
;; nonexistent folder.
|
;; nonexistent folder.
|
||||||
|
|
@ -441,10 +456,8 @@ and the `should' macro requires idempotent evaluation anyway."
|
||||||
|
|
||||||
(ert-deftest mh-folder-completion-function-08-plus-slash ()
|
(ert-deftest mh-folder-completion-function-08-plus-slash ()
|
||||||
"Test `mh-folder-completion-function' with `+/'."
|
"Test `mh-folder-completion-function' with `+/'."
|
||||||
;; This test fails with Mailutils 3.5, 3.7, and 3.13.
|
|
||||||
(with-mh-test-env
|
(with-mh-test-env
|
||||||
(skip-unless (not (and (stringp mh-variant-in-use)
|
(skip-unless (mh-test-variant-handles-plus-slash mh-variant-in-use)))
|
||||||
(string-search "GNU Mailutils" mh-variant-in-use)))))
|
|
||||||
(mh-test-folder-completion-1 "+/" "+/" "tmp/" t)
|
(mh-test-folder-completion-1 "+/" "+/" "tmp/" t)
|
||||||
;; case "bb"
|
;; case "bb"
|
||||||
(with-mh-test-env
|
(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 ()
|
(ert-deftest mh-folder-completion-function-09-plus-slash-tmp ()
|
||||||
"Test `mh-folder-completion-function' with `+/tmp'."
|
"Test `mh-folder-completion-function' with `+/tmp'."
|
||||||
;; This test fails with Mailutils 3.5, 3.7, and 3.13.
|
|
||||||
(with-mh-test-env
|
(with-mh-test-env
|
||||||
(skip-unless (not (and (stringp mh-variant-in-use)
|
(skip-unless (mh-test-variant-handles-plus-slash mh-variant-in-use)))
|
||||||
(string-search "GNU Mailutils" mh-variant-in-use)))))
|
|
||||||
(mh-test-folder-completion-1 "+/tmp" "+/tmp/" "tmp/" t))
|
(mh-test-folder-completion-1 "+/tmp" "+/tmp/" "tmp/" t))
|
||||||
|
|
||||||
(ert-deftest mh-folder-completion-function-10-plus-slash-abs-folder ()
|
(ert-deftest mh-folder-completion-function-10-plus-slash-abs-folder ()
|
||||||
|
|
|
||||||
|
|
@ -79,12 +79,10 @@ for path in "${mh_sys_path[@]}"; do
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "Testing with PATH $path"
|
echo "** Testing with PATH $path"
|
||||||
((++tests_total))
|
((++tests_total))
|
||||||
# The LD_LIBRARY_PATH setting is needed
|
|
||||||
# to run locally installed Mailutils.
|
|
||||||
TEST_MH_PATH=$path TEST_MH_DEBUG=$debug \
|
TEST_MH_PATH=$path TEST_MH_DEBUG=$debug \
|
||||||
LD_LIBRARY_PATH=/usr/local/lib HOME=/nonexistent \
|
HOME=/nonexistent \
|
||||||
"${emacs[@]}" -l ert \
|
"${emacs[@]}" -l ert \
|
||||||
--eval "(setq load-prefer-newer t)" \
|
--eval "(setq load-prefer-newer t)" \
|
||||||
--eval "(load \"$PWD/test/lisp/mh-e/mh-utils-tests\" nil t)" \
|
--eval "(load \"$PWD/test/lisp/mh-e/mh-utils-tests\" nil t)" \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue