Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextest integration to run test at a point #64

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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