Skip to content

Instantly share code, notes, and snippets.

@tonini
Created December 31, 2014 12:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonini/42420f0248cfd49daa23 to your computer and use it in GitHub Desktop.
Save tonini/42420f0248cfd49daa23 to your computer and use it in GitHub Desktop.
(defun tester (&rest cl-keys)
(cl--parsing-keywords ((:function nil) (:match nil)) nil
(if (and buffer-file-name (string-match cl-match buffer-file-name))
(setq tester--test-run-function cl-function)
(setq tester--test-run-function nil))))
(defun tester--store-setup ()
(setq tester--last-test-file buffer-file-name)
(setq tester--last-test-function tester--test-run-function))
(defun tester--stored-setup-p ()
(and tester--last-test-file
tester--last-test-function))
(defun tester-run ()
(interactive)
(cond (tester--test-run-function
(tester--store-setup)
(funcall tester--test-run-function buffer-file-name))
((tester--stored-setup-p)
(funcall tester--last-test-function tester--last-test-file))
(t
(message "Please setup a function for running tests."))))
(defun tonini-elixir-setup-hook ()
(tester :function 'alchemist-mix-test-file :match "_test.exs"))
(add-hook 'elixir-mode-hook 'tonini-elixir-setup-hook)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment