Skip to content

Commit 009675a

Browse files
authored
Merge pull request #87 from emacs-rustic/nextest-attempt-two
Integration with cargo nextest
2 parents fbbf0a7 + bc6b0ea commit 009675a

File tree

2 files changed

+16
-28
lines changed

2 files changed

+16
-28
lines changed

CHANGELOG.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Fixed an issue where workspaces were not resolved correctly over TRAMP.
1010
- Implement ~rustic-cargo-test-rerun-current~ for rerunning the
1111
current test from the compile buffer.
12+
- Provde integration with [[https://nexte.st/][cargo nextest]]
1213

1314
* 3.5
1415

rustic-cargo.el

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@
2929
:type 'string
3030
:group 'rustic-cargo)
3131

32-
(defcustom rustic-cargo-nextest-exec-command "nextest run"
33-
"Execute command to run `nextest'."
32+
(defcustom rustic-cargo-test-runner 'cargo
33+
"Test runner to use for running tests. By default uses cargo."
34+
:type '(choice (const cargo)
35+
(const nextest))
36+
:group 'rustic-cargo)
37+
38+
(defcustom rustic-cargo-nextest-exec-command (list "nextest" "run")
39+
"Execute command to run nextest."
3440
:type 'string
3541
:group 'rustic-cargo)
3642

@@ -188,37 +194,18 @@ stored in this variable.")
188194
(when rustic-cargo-test-disable-warnings
189195
(setq-local rustic-compile-rustflags (concat rustic-compile-rustflags " -Awarnings"))))
190196

191-
(defun rustic-cargo-run-nextest (&optional arg)
192-
"Command for running nextest.
193-
194-
If ARG is not nil, get input from minibuffer."
195-
(interactive "P")
196-
(let* ((nextest (if arg
197-
(read-from-minibuffer "nextest command: " rustic-cargo-nextest-exec-command)
198-
rustic-cargo-nextest-exec-command))
199-
(c (-flatten (list (rustic-cargo-bin) (split-string nextest))))
200-
(buf rustic-test-buffer-name)
201-
(proc rustic-test-process-name)
202-
(mode 'rustic-cargo-test-mode))
203-
(rustic-compilation c (list :buffer buf :process proc :mode mode))))
204-
205-
(defun rustic-cargo-nextest-current-test ()
206-
"Run `cargo nextest run' for the test near point."
207-
(interactive)
208-
(rustic-compilation-process-live)
209-
(-if-let (test-to-run (setq rustic-test-arguments
210-
(rustic-cargo--get-test-target)))
211-
(let ((rustic-cargo-nextest-exec-command
212-
(format "%s %s" rustic-cargo-nextest-exec-command test-to-run)))
213-
(rustic-cargo-run-nextest))
214-
(message "Could not find test at point.")))
197+
(defun rustic--cargo-test-runner ()
198+
"Return the test runner command."
199+
(cond ((eq rustic-cargo-test-runner 'cargo) rustic-cargo-test-exec-command)
200+
((eq rustic-cargo-test-runner 'nextest) rustic-cargo-nextest-exec-command)
201+
(t (user-error "Invalid configured value for rustic-cargo-test-runner variable"))))
215202

216203
;;;###autoload
217204
(defun rustic-cargo-test-run (&optional test-args)
218205
"Start compilation process for `cargo test' with optional TEST-ARGS."
219206
(interactive)
220207
(rustic-compilation-process-live)
221-
(let* ((command (list (rustic-cargo-bin) rustic-cargo-test-exec-command))
208+
(let* ((command (flatten-list (list (rustic-cargo-bin) (rustic--cargo-test-runner))))
222209
(c (append command (split-string (if test-args test-args ""))))
223210
(buf rustic-test-buffer-name)
224211
(proc rustic-test-process-name)
@@ -297,7 +284,7 @@ If ARG is not nil, use value as argument and store it in
297284

298285
(defun rustic-cargo-run-test (test)
299286
"Run TEST which can be a single test or mod name."
300-
(let* ((c (list (rustic-cargo-bin) rustic-cargo-test-exec-command test))
287+
(let* ((c (flatten-list (list (rustic-cargo-bin) (rustic--cargo-test-runner) test)))
301288
(buf rustic-test-buffer-name)
302289
(proc rustic-test-process-name)
303290
(mode 'rustic-cargo-test-mode))

0 commit comments

Comments
 (0)