Skip to content

Commit 5a2a79d

Browse files
authored
Merge pull request #64 from emacs-rustic/rustic-nextest
nextest integration to run test at a point
2 parents f2379e8 + 00dc8e1 commit 5a2a79d

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.org

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
option. This is handy when you are working on multiple
55
projects. Refer the variable docs and README for more details.
66
- Replace Cask with Eask for CI testing.
7+
- Implement ~rustic-cargo-nextest-current-test~ for running test at a
8+
point using nextest.
79

810
* 3.5
911

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,8 @@ Commands:
558558
- `rustic-cargo-current-test` run test at point, whether it's a
559559
function or a module
560560
- `rustic-cargo-run-nextest` command for running [nextest](https://github.com/nextest-rs/nextest)
561+
- `rustic-cargo-nextest-current-test` is the nextest equivalent for
562+
`rustic-cargo-current-test`
561563

562564
![](https://raw.githubusercontent.com/emacs-rustic/rustic/main/img/cargo_current_test.png)
563565

rustic-cargo.el

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ stored in this variable.")
184184
(setq-local rustic-compile-rustflags (concat rustic-compile-rustflags " -Awarnings"))))
185185

186186
(defun rustic-cargo-run-nextest (&optional arg)
187-
"Command for running nextest."
187+
"Command for running nextest.
188+
189+
If ARG is not nil, get input from minibuffer."
188190
(interactive "P")
189191
(let* ((nextest (if arg
190192
(read-from-minibuffer "nextest command: " rustic-cargo-nextest-exec-command)
@@ -195,6 +197,17 @@ stored in this variable.")
195197
(mode 'rustic-cargo-test-mode))
196198
(rustic-compilation c (list :buffer buf :process proc :mode mode))))
197199

200+
(defun rustic-cargo-nextest-current-test ()
201+
"Run 'cargo nextest run' for the test near point."
202+
(interactive)
203+
(rustic-compilation-process-live)
204+
(-if-let (test-to-run (setq rustic-test-arguments
205+
(rustic-cargo--get-test-target)))
206+
(let ((rustic-cargo-nextest-exec-command
207+
(format "%s %s" rustic-cargo-nextest-exec-command test-to-run)))
208+
(rustic-cargo-run-nextest))
209+
(message "Could not find test at point.")))
210+
198211
;;;###autoload
199212
(defun rustic-cargo-test-run (&optional test-args)
200213
"Start compilation process for 'cargo test' with optional TEST-ARGS."

0 commit comments

Comments
 (0)