Skip to content

Commit

Permalink
[emacs] Use absolute path for mix when running tests
Browse files Browse the repository at this point in the history
This allow to use nix paths which can be different by project,
version, etc
  • Loading branch information
erickgnavar committed Oct 27, 2024
1 parent 14bbb54 commit 451a277
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions .emacs.d/bootstrap.org
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,10 @@ Custom functions to run elixir tests.
(defun my/mix-run-test (&optional scope)
"Run elixir test for the given SCOPE."
(interactive)
(let* ((current-file (buffer-file-name))
;; we need to get absolute path of mix binary because when running
;; on nix this path will be different per project, version, etc
(let* ((mix-binary (executable-find "mix"))
(current-file (buffer-file-name))
(current-line (line-number-at-pos))
(mix-file (expand-file-name (concat (locate-dominating-file (buffer-file-name) "mix.exs") "mix.exs")))
(default-directory (file-name-directory mix-file))
Expand All @@ -2341,14 +2344,13 @@ Custom functions to run elixir tests.

(cond
((string-equal scope "file")
(compile (format "%s mix test %s" mix-env current-file)))
(compile (format "%s %s test %s" mix-env mix-binary current-file)))

((string-equal scope "at-point")
(compile (format "%s mix test %s:%s" mix-env current-file current-line)))
(compile (format "%s %s test %s:%s" mix-env mix-binary current-file current-line)))

(t
(compile (format "%s mix test" mix-env))))))

(compile (format "%s %s test" mix-env mix-binary))))))

(defun my/mix-run-test-file ()
"Run mix test over the current file."
Expand Down

0 comments on commit 451a277

Please sign in to comment.