From 7e735808e966d70340b5a2cef0430f913151d9b6 Mon Sep 17 00:00:00 2001 From: Oleh Krehel Date: Wed, 10 Apr 2019 11:42:11 +0200 Subject: [PATCH] ivy-test.el (counsel-find-file-with-dollars): Add test Re #2012 --- ivy-test.el | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ivy-test.el b/ivy-test.el index fa039070..20daa9d3 100644 --- a/ivy-test.el +++ b/ivy-test.el @@ -48,13 +48,17 @@ (global-set-key (kbd "C-c e") 'ivy-eval) -(defun ivy-with (expr keys) +(cl-defun ivy-with (expr keys &key dir) "Evaluate EXPR followed by KEYS." (let ((ivy-expr expr) (inhibit-message t)) - (execute-kbd-macro - (vconcat (kbd "C-c e") - (kbd keys))) + (save-window-excursion + ;; `execute-kbd-macro' doesn't pick up `default-directory' + (when dir + (dired (expand-file-name dir (counsel-locate-git-root)))) + (execute-kbd-macro + (vconcat (kbd "C-c e") + (kbd keys)))) ivy-result)) (defun command-execute-setting-this-command (cmd &rest args) @@ -1071,6 +1075,16 @@ a buffer visiting a file." "C-p C-m") "")))) +(unless (file-exists-p "test") + (shell-command "git clone -b test --single-branch https://github.com/abo-abo/swiper/ test")) + +(ert-deftest counsel-find-file-with-dollars () + (should (string= + (file-relative-name + (ivy-with '(counsel-find-file) "fo C-m" + :dir "test/find-file/files-with-dollar/")) + "test/find-file/files-with-dollar/foo$"))) + (provide 'ivy-test) ;;; ivy-test.el ends here