Update mocha-run to use compile instead of compilation-start
felipeochoa opened this issue · comments
Felipe commented
The way it's currently set up, mocha-run
manually creates the test output buffer and then calls compilation-start
to get compilation started. compilation-start
is documented as a low-level interface, and this use
prevents any buffer-local bindings from affecting the compilation run.
A better way of starting compilation is to let-bind the proper variables and then call compile
, letting it create the buffer, etc.
@@ -148,16 +148,12 @@ If MOCHA-FILE is specified run just that file otherwise run
MOCHA-PROJECT-TEST-DIRECTORY.
IF TEST is specified run mocha with a grep for just that test."
- (save-some-buffers (not compilation-ask-about-save)
- (when (boundp 'compilation-save-buffers-predicate)
- compilation-save-buffers-predicate))
-
(when (get-buffer "*mocha tests*")
(kill-buffer "*mocha tests*"))
- (let ((test-command-to-run (mocha-generate-command nil mocha-file test)) (root-dir (mocha-find-project-root)))
- (with-current-buffer (get-buffer-create "*mocha tests*")
- (setq default-directory root-dir)
- (compilation-start test-command-to-run 'mocha-compilation-mode (lambda (m) (buffer-name))))))
+ (let ((test-command-to-run (mocha-generate-command nil mocha-file test))
+ (default-directory (mocha-find-project-root))
+ (compilation-buffer-name-function (lambda (_) "" "*mocha tests*")))
+ (compile test-command-to-run 'mocha-compilation-mode)))