Skip to content

Instantly share code, notes, and snippets.

@vinikira
Created September 12, 2020 00:04
Show Gist options
  • Save vinikira/daa90358d29266517b894b9a7c2e6eac to your computer and use it in GitHub Desktop.
Save vinikira/daa90358d29266517b894b9a7c2e6eac to your computer and use it in GitHub Desktop.
Adivice emacs exunit to use a custom mix command (e.g a docker container)
((elixir-mode . ((my/use-exunit-custom . t)
(my/exunit-custom-mix-cmd . "docker exec -it <container_id_or_name> mix"))))
;; advice exunit execution to use Doca
(defvar my/use-exunit-custom nil)
(defvar my/exunit-custom-mix-cmd "docker exec -it <container_id_or_name> mix")
(defun my/exunit-compile (orig-fun &rest args)
(if my/use-exunit-custom
(let* ((directory (cadr args))
(default-directory (or directory (exunit-project-root)))
(compilation-environment exunit-environment)
(args (car args)))
(exunit-do-compile
(s-join " " (append (list my/exunit-custom-mix-cmd "test") exunit-mix-test-default-options args))))
(apply orig-fun args)))
(advice-add 'exunit-compile :around #'my/exunit-compile)
;; to remove
;; (advice-remove 'exunit-compile #'my/exunit-compile)
@vinikira
Copy link
Author

Customize and move code from .dir-locals.el to root of your Elixir project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment