Skip to content

Commit

Permalink
minitest-run-file to run a specific file.
Browse files Browse the repository at this point in the history
This makes it easier for third party code to integrate with minitest-emacs.
It's now possible to give minitest-emcas only a filename. The function
`minitest-run-file` is meant for scripting and is not interactive.
  • Loading branch information
senny committed Apr 4, 2016
1 parent 263d3f0 commit 4b8df3b
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions minitest.el
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,9 @@ The current directory is assumed to be the project's root otherwise."

(defun minitest--file-command (&optional post-command)
"Run COMMAND on currently visited file."
(let ((file-name (file-relative-name (buffer-file-name) (minitest-project-root)))
(bundle (minitest-bundler-command))
(command (minitest-test-command)))
(let ((file-name (file-relative-name (buffer-file-name) (minitest-project-root))))
(if file-name
(minitest--run-command
(mapconcat 'shell-quote-argument
(-flatten
(--remove (eq nil it)
(list bundle command file-name post-command))) " ")
file-name)
(minitest-run-file file-name)
(error "Buffer is not visiting a file"))))

(defun minitest--test-name-flag (test-name)
Expand Down Expand Up @@ -155,6 +148,17 @@ The current directory is assumed to be the project's root otherwise."
(apply #'minitest--run-command minitest--last-command)
(error "There is no previous command to run")))

(defun minitest-run-file (file-name &optional post-command)
"Run the given file"
(let ((bundle (minitest-bundler-command))
(command (minitest-test-command)))
(minitest--run-command
(mapconcat 'shell-quote-argument
(-flatten
(--remove (eq nil it)
(list bundle command file-name post-command))) " ")
file-name)))

;;; Minor mode
(defvar minitest-mode-map
(let ((map (make-sparse-keymap)))
Expand Down

0 comments on commit 4b8df3b

Please sign in to comment.