[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master f1fcd32: mh-utils-tests: Add new tests of "folders +/"
From: |
Stephen Gildea |
Subject: |
master f1fcd32: mh-utils-tests: Add new tests of "folders +/" |
Date: |
Wed, 24 Nov 2021 10:28:41 -0500 (EST) |
branch: master
commit f1fcd321ff40315442cd77084c444585948bea85
Author: Stephen Gildea <stepheng+emacs@gildea.com>
Commit: Stephen Gildea <stepheng+emacs@gildea.com>
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.
---
test/lisp/mh-e/mh-utils-tests.el | 47 +++++++++++++++++++++-------------
test/lisp/mh-e/test-all-mh-variants.sh | 6 ++---
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 0066c00..5f6accc 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."
(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 ()
diff --git a/test/lisp/mh-e/test-all-mh-variants.sh
b/test/lisp/mh-e/test-all-mh-variants.sh
index e917d81..eaee98f 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
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)" \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master f1fcd32: mh-utils-tests: Add new tests of "folders +/",
Stephen Gildea <=