Skip to content

Commit 3dbbd1b

Browse files
committed
Fix tests to run under Emacs 24.3.
The order of results in Emacs 24 are not always consistent with other Emacs versions.
1 parent 7a1f127 commit 3dbbd1b

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

test/bash-completion-integration-test.el

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,16 @@ for testing completion."
181181
(delete-directory test-env-dir 'recursive)
182182
(dired-delete-file test-env-dir 'always))))
183183

184+
(defun bash-completion_test-equal-any-order (expected actual)
185+
"Compare a sorted list of string EXPECTED with ACTUAL.
186+
187+
Ignore the order of the strings in ACTUAL.
188+
189+
This is necessary, because the order of some results isn't stable
190+
across Emacs version."
191+
(let ((actual (copy-tree actual)))
192+
(equal expected (sort actual 'string<))))
193+
184194
(ert-deftest bash-completion-integration-setenv-test ()
185195
(bash-completion_test-harness
186196
""
@@ -238,8 +248,9 @@ for testing completion."
238248
(bash-completion_test-with-shell-harness
239249
bashrc
240250
nil ; use-separate-process
241-
(should (equal '("some/directory/" "some/other/")
242-
(sort (bash-completion_test-candidates "ls some/") 'string<)))
251+
(should (bash-completion_test-equal-any-order
252+
'("some/directory/" "some/other/")
253+
(bash-completion_test-candidates "ls some/")))
243254
(should (equal '("some/directory/") (bash-completion_test-candidates "ls some/d")))
244255
(should (equal '("some/directory/") (bash-completion_test-candidates "ls some/di")))
245256
(should (equal '() (bash-completion_test-candidates "ls some/do")))))
@@ -598,7 +609,8 @@ $ ")))))
598609
;; https://www.gnu.org/software/emacs/manual/html_node/elisp/Programmed-Completion.html
599610

600611
;; all-completion
601-
(should (equal '("some/file/" "some/filled/") (funcall compfunc-some "some/" nil t)))
612+
(should (bash-completion_test-equal-any-order
613+
'("some/file/" "some/filled/") (funcall compfunc-some "some/" nil t)))
602614
(should (equal '("some/filled/") (funcall compfunc-some "some/fill" nil t)))
603615
(should (equal nil (funcall compfunc-some "other" nil t)))
604616
(should (equal '("some/filled/") (funcall compfunc-one "some/fill" nil t)))
@@ -609,8 +621,9 @@ $ ")))))
609621
(lambda (c) (string= c "some/file/")) t)))
610622
(should (equal nil
611623
(funcall compfunc-some "some/" (lambda (c) nil) t)))
612-
(should (equal '("some/file/" "some/filled/")
613-
(funcall compfunc-some "some/" (lambda (c) t) t)))
624+
(should (bash-completion_test-equal-any-order
625+
'("some/file/" "some/filled/")
626+
(funcall compfunc-some "some/" (lambda (c) t) t)))
614627

615628
;; try-completion
616629
(should (equal "some/filled/" (funcall compfunc-one "some/fill" nil nil)))
@@ -667,8 +680,8 @@ $ ")))))
667680
(ert-deftest bash-completion_test-dynamic-table-nonprefix ()
668681
(bash-completion_test-with-shell-harness
669682
(concat "function _myprog {\n"
670-
" COMPREPLY=( \"ba${COMP_WORDS[$COMP_CWORD]}tai\" \n"
671-
" \"ba${COMP_WORDS[$COMP_CWORD]}dai\" )\n"
683+
" COMPREPLY=( \"ba${COMP_WORDS[$COMP_CWORD]}dai\" \n"
684+
" \"ba${COMP_WORDS[$COMP_CWORD]}tai\" )\n"
672685
"}\n"
673686
"complete -F _myprog myprog\n")
674687
nil ; use-separate-process
@@ -683,8 +696,10 @@ $ ")))))
683696
;; text string, so the first time all-completion is called with
684697
;; the current word, all completions are returned, even the one
685698
;; that don't match the string as prefix.
686-
(should (equal '("babeetai" "babeedai") (funcall compfunc-nonprefix "bee" nil t)))
687-
(should (equal '("babeetai" "babeedai") (funcall compfunc-nonprefix "babee" nil t)))
699+
(should (bash-completion_test-equal-any-order
700+
'("babeedai" "babeetai") (funcall compfunc-nonprefix "bee" nil t)))
701+
(should (bash-completion_test-equal-any-order
702+
'("babeedai" "babeetai") (funcall compfunc-nonprefix "babee" nil t)))
688703
(should (equal '("babeetai") (funcall compfunc-nonprefix "babeet" nil t)))
689704

690705
;; all-completion with predicate

0 commit comments

Comments
 (0)