Skip to content

Commit

Permalink
Merge pull request #64 from emacs-rustic/rustic-nextest
Browse files Browse the repository at this point in the history
nextest integration to run test at a point
  • Loading branch information
psibi authored Nov 7, 2024
2 parents f2379e8 + 00dc8e1 commit 5a2a79d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
option. This is handy when you are working on multiple
projects. Refer the variable docs and README for more details.
- Replace Cask with Eask for CI testing.
- Implement ~rustic-cargo-nextest-current-test~ for running test at a
point using nextest.

* 3.5

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,8 @@ Commands:
- `rustic-cargo-current-test` run test at point, whether it's a
function or a module
- `rustic-cargo-run-nextest` command for running [nextest](https://github.com/nextest-rs/nextest)
- `rustic-cargo-nextest-current-test` is the nextest equivalent for
`rustic-cargo-current-test`

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

Expand Down
15 changes: 14 additions & 1 deletion rustic-cargo.el
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ stored in this variable.")
(setq-local rustic-compile-rustflags (concat rustic-compile-rustflags " -Awarnings"))))

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

(defun rustic-cargo-nextest-current-test ()
"Run 'cargo nextest run' for the test near point."
(interactive)
(rustic-compilation-process-live)
(-if-let (test-to-run (setq rustic-test-arguments
(rustic-cargo--get-test-target)))
(let ((rustic-cargo-nextest-exec-command
(format "%s %s" rustic-cargo-nextest-exec-command test-to-run)))
(rustic-cargo-run-nextest))
(message "Could not find test at point.")))

;;;###autoload
(defun rustic-cargo-test-run (&optional test-args)
"Start compilation process for 'cargo test' with optional TEST-ARGS."
Expand Down

0 comments on commit 5a2a79d

Please sign in to comment.