|
142 | 142 | (or end (point-max)))) |
143 | 143 |
|
144 | 144 | (defun bash-completion_test-candidates (complete-me) |
145 | | - "Complete COMPLETE-ME and returns the candidates." |
| 145 | + "Complete COMPLETE-ME and returns the candidates. |
| 146 | +
|
| 147 | +The result is sorted to avoid hardcoding arbitrary order in the test." |
146 | 148 | (goto-char (point-max)) |
147 | 149 | (delete-region (line-beginning-position) (line-end-position)) |
148 | 150 | (insert complete-me) |
149 | | - (nth 2 (bash-completion-dynamic-complete-nocomint))) |
| 151 | + (sort |
| 152 | + (nth 2 (bash-completion-dynamic-complete-nocomint |
| 153 | + (line-beginning-position) (point) nil)) |
| 154 | + 'string<)) |
150 | 155 |
|
151 | 156 | (defun bash-completion_test-setup-env (bashrc) |
152 | 157 | "Sets up a directory that contains a bashrc file other files |
@@ -224,6 +229,23 @@ for testing completion." |
224 | 229 | (bash-completion_test-complete |
225 | 230 | "export SOMEPATH=some/directory:some/oth"))))) |
226 | 231 |
|
| 232 | +(ert-deftest bash-completion-integration-multiple-completions-test () |
| 233 | + (bash-completion_test-multiple-completions-test "")) |
| 234 | + |
| 235 | +(ert-deftest bash-completion-integration-multiple-completions-prog-test () |
| 236 | + (bash-completion_test-multiple-completions-test |
| 237 | + (concat "source " bash-completion_test-setup-completion "\n"))) |
| 238 | + |
| 239 | +(defun bash-completion_test-multiple-completions-test (bashrc) |
| 240 | + (bash-completion_test-with-shell-harness |
| 241 | + bashrc |
| 242 | + nil ; use-separate-process |
| 243 | + (should (equal '("some/directory/" "some/other/") |
| 244 | + (sort (bash-completion_test-candidates "ls some/") 'string<))) |
| 245 | + (should (equal '("some/directory/") (bash-completion_test-candidates "ls some/d"))) |
| 246 | + (should (equal '("some/directory/") (bash-completion_test-candidates "ls some/di"))) |
| 247 | + (should (equal '() (bash-completion_test-candidates "ls some/do"))))) |
| 248 | + |
227 | 249 | (ert-deftest bash-completion-integration-nocomint-test () |
228 | 250 | (bash-completion_test-harness |
229 | 251 | "function somefunction { echo ok; }\n" |
|
0 commit comments