diff --git a/CHANGELOG.org b/CHANGELOG.org
index 95b0bb8..b928488 100644
--- a/CHANGELOG.org
+++ b/CHANGELOG.org
@@ -4,11 +4,7 @@
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.
-- Fixed an issue where workspaces were not resolved correctly over TRAMP.
-- Implement ~rustic-cargo-test-rerun-current~ for rerunning the
- current test from the compile buffer.
+- Provde integration with [[https://nexte.st/][cargo nextest]]
* 3.5
diff --git a/README.md b/README.md
index 6b73590..92b822f 100644
--- a/README.md
+++ b/README.md
@@ -531,40 +531,6 @@ to Cargo.toml by checking new diagnostics for 'unresolved import' errors
- `rustic-cargo-use-last-stored-arguments` always use stored arguments that were provided with `C-u`(instead of requiring to run rustic "rerun" commands)
- `rustic-cargo-populate-package-name` for auto populating the correct package name when used with universal argument. This comes in handy when you are working with multiple projects. Not enabled by default, but recommened to enable it.
-
-### Keybindings
-
-Note that most commands support editing the exact `cargo` arguments and flags when called with the
-prefix `C-u`.
-
- Keybinding | Command
-------------------------|----------------------
- C-c C-p | rustic-popup
- C-c C-c C-u | rustic-compile
- C-c C-c C-i | rustic-recompile
- C-c C-c C-o | rustic-format-buffer
- C-c C-c C-, | rustic-docstring-dwim
- C-c C-c C-b | rustic-cargo-build
- C-c C-c C-k | rustic-cargo-check
- C-c C-c C-r | rustic-cargo-run
- C-c C-c C-f | rustic-cargo-fmt
- C-c C-c C-t | rustic-cargo-test
- C-c C-c C-c | rustic-cargo-current-test
- C-c C-c C-l | rustic-cargo-clippy
- C-c C-c C-n | rustic-cargo-outdated
- C-c C-c n | rustic-cargo-new
- C-c C-c i | rustic-cargo-init
- C-c C-c b | rustic-cargo-bench
- C-c C-c d | rustic-cargo-doc
- C-c C-c c | rustic-cargo-clean
- C-c C-c k | rustic-cargo-clippy
- C-c C-c f | rustic-cargo-clippy-fix
- C-c C-c a | rustic-cargo-add
- C-c C-c r | rustic-cargo-rm
- C-c C-c u | rustic-cargo-upgrade
-
- More details on each command below
-
### Edit
[cargo-edit](https://github.com/killercup/cargo-edit) provides commands to edit
@@ -585,15 +551,15 @@ If you want to disable warnings when running cargo-test commands, you can set
Commands:
-- `rustic-cargo-test` run 'cargo test', when called with `C-u` edit the command
- before running and store in `rustic-test-arguments`.
-- `rustic-cargo-test-rerun` (`g` from compile buffer) rerun 'cargo test' with arguments stored in
- `rustic-test-arguments`
-- `rustic-cargo-current-test` run test at point, whether it's a function or a module
-- `rustic-cargo-test-rerun-current` (`C-c C-t` or `t` from compile buffer) re-run the test at point
- from the `*cargo-test*` compile buffer.
+- `rustic-cargo-test` run 'cargo test', when called with `C-u` store
+ arguments in `rustic-test-arguments`
+- `rustic-cargo-test-rerun` rerun 'cargo test' with arguments stored
+ in `rustic-test-arguments`
+- `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`
+- `rustic-cargo-nextest-current-test` is the nextest equivalent for
+ `rustic-cargo-current-test`

diff --git a/rustic-cargo.el b/rustic-cargo.el
index b6d0f26..aa72382 100644
--- a/rustic-cargo.el
+++ b/rustic-cargo.el
@@ -29,8 +29,14 @@
:type 'string
:group 'rustic-cargo)
-(defcustom rustic-cargo-nextest-exec-command "nextest run"
- "Execute command to run `nextest'."
+(defcustom rustic-cargo-test-runner 'cargo
+ "Test runner to use for running tests. By default uses cargo."
+ :type '(choice (const cargo)
+ (const nextest))
+ :group 'rustic-cargo)
+
+(defcustom rustic-cargo-nextest-exec-command (list "nextest" "run")
+ "Execute command to run nextest."
:type 'string
:group 'rustic-cargo)
@@ -170,6 +176,7 @@ Currently only working with lsp-mode."
Tests that are executed by `rustic-cargo-current-test' will also be
stored in this variable.")
+
(defvar rustic-test-history nil
"Holds previous arguments for `cargo test', similar to `compile-arguments`.")
@@ -177,8 +184,6 @@ stored in this variable.")
(let ((map (make-sparse-keymap)))
(set-keymap-parent map rustic-compilation-mode-map)
(define-key map [remap recompile] 'rustic-cargo-test-rerun)
- (define-key map (kbd "C-c C-t") 'rustic-cargo-test-rerun-current)
- (define-key map (kbd "t") 'rustic-cargo-test-rerun-current)
map)
"Local keymap for `rustic-cargo-test-mode' buffers.")
@@ -188,37 +193,18 @@ stored in this variable.")
(when rustic-cargo-test-disable-warnings
(setq-local rustic-compile-rustflags (concat rustic-compile-rustflags " -Awarnings"))))
-(defun rustic-cargo-run-nextest (&optional arg)
- "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)
- rustic-cargo-nextest-exec-command))
- (c (-flatten (list (rustic-cargo-bin) (split-string nextest))))
- (buf rustic-test-buffer-name)
- (proc rustic-test-process-name)
- (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.")))
+(defun rustic--cargo-test-runner ()
+ "Return the test runner command. IS-FILTER indicates if only specific test are filtered."
+ (cond ((eq rustic-cargo-test-runner 'cargo) rustic-cargo-test-exec-command)
+ ((eq rustic-cargo-test-runner 'nextest) rustic-cargo-nextest-exec-command)
+ (t (user-error "Invalid configured value for rustic-cargo-test-runner variable"))))
;;;###autoload
(defun rustic-cargo-test-run (&optional test-args)
"Start compilation process for `cargo test' with optional TEST-ARGS."
(interactive)
(rustic-compilation-process-live)
- (let* ((command (list (rustic-cargo-bin) rustic-cargo-test-exec-command))
+ (let* ((command (flatten-list (list (rustic-cargo-bin) (rustic--cargo-test-runner))))
(c (append command (split-string (if test-args test-args ""))))
(buf rustic-test-buffer-name)
(proc rustic-test-process-name)
@@ -242,8 +228,7 @@ If ARG is not nil, use value as argument and store it in
(list (rustic-cargo-package-argument)
rustic-test-arguments
rustic-cargo-build-arguments
- rustic-default-test-arguments))
- nil nil 'rustic-test-history)))
+ rustic-default-test-arguments)))))
(rustic-cargo-use-last-stored-arguments
(if (> (length rustic-test-arguments) 0)
rustic-test-arguments
@@ -289,15 +274,12 @@ If ARG is not nil, use value as argument and store it in
(rustic-compilation-process-live)
(-if-let (test-to-run (setq rustic-test-arguments
(rustic-cargo--get-test-target)))
- (progn
- (unless (equal (car rustic-test-history) test-to-run)
- (push test-to-run rustic-test-history))
- (rustic-cargo-run-test test-to-run))
+ (rustic-cargo-run-test test-to-run)
(message "Could not find test at point.")))
(defun rustic-cargo-run-test (test)
"Run TEST which can be a single test or mod name."
- (let* ((c (list (rustic-cargo-bin) rustic-cargo-test-exec-command test))
+ (let* ((c (flatten-list (list (rustic-cargo-bin) (rustic--cargo-test-runner) test)))
(buf rustic-test-buffer-name)
(proc rustic-test-process-name)
(mode 'rustic-cargo-test-mode))
@@ -712,9 +694,7 @@ When calling this function from `rustic-popup-mode', always use the value of
(interactive "P")
(rustic-cargo-run-command
(cond (arg
- (setq rustic-run-arguments
- (read-from-minibuffer "Cargo run arguments: "
- rustic-run-arguments nil nil 'rustic-run-history)))
+ (setq rustic-run-arguments (read-from-minibuffer "Cargo run arguments: " rustic-run-arguments)))
(rustic-cargo-use-last-stored-arguments
rustic-run-arguments)
((rustic--get-run-arguments))
@@ -725,11 +705,6 @@ When calling this function from `rustic-popup-mode', always use the value of
"Run `cargo run' with `rustic-run-arguments'."
(interactive "P")
(let ((default-directory (or rustic-compilation-directory default-directory)))
- (setq rustic-run-arguments
- (if arg
- (read-from-minibuffer "cargo run arguments: "
- rustic-run-arguments nil nil 'rustic-run-history)
- rustic-run-arguments))
(rustic-cargo-run-command rustic-run-arguments)))
(defun rustic--get-run-arguments ()
diff --git a/rustic-compile.el b/rustic-compile.el
index 76d30d3..ee19cbb 100644
--- a/rustic-compile.el
+++ b/rustic-compile.el
@@ -565,11 +565,10 @@ It's a list that looks like (list command mode name-function highlight-regexp)."
(setq compilation-arguments (list command nil nil nil)))
;;;###autoload
-(defun rustic-recompile (arg)
+(defun rustic-recompile ()
"Re-compile the program using `compilation-arguments'."
- (interactive "P")
- (let* ((comp-arguments (or (car compilation-arguments) (format "%s %s" (rustic-compile-command) rustic-cargo-build-arguments)))
- (command (if arg (read-from-minibuffer "recompile: " comp-arguments) comp-arguments))
+ (interactive)
+ (let* ((command (or (car compilation-arguments) (format "%s %s" (rustic-compile-command) rustic-cargo-build-arguments)))
(dir compilation-directory))
(rustic-compilation-process-live)
(rustic-compilation-start (split-string command)
diff --git a/rustic.el b/rustic.el
index e85a333..67d76c3 100644
--- a/rustic.el
+++ b/rustic.el
@@ -89,20 +89,17 @@ as for that macro."
;; this variable is buffer local so we can use the cached value
(if rustic--buffer-workspace
rustic--buffer-workspace
- ;; Resolve the bin path while still buffer local (in cases like
- ;; remote via TRAMP)
- (let ((cargo-bin (rustic-cargo-bin)))
- (rustic--with-temp-process-buffer
- (let ((ret (process-file cargo-bin nil (list (current-buffer) nil) nil "locate-project" "--workspace")))
- (cond ((and (/= ret 0) nodefault)
- (error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))
- ((and (/= ret 0) (not nodefault))
- (setq rustic--buffer-workspace default-directory))
- (t
- (goto-char 0)
- (let* ((output (json-read))
- (dir (file-name-directory (cdr (assoc-string "root" output)))))
- (setq rustic--buffer-workspace dir)))))))))
+ (rustic--with-temp-process-buffer
+ (let ((ret (process-file (rustic-cargo-bin) nil (list (current-buffer) nil) nil "locate-project" "--workspace")))
+ (cond ((and (/= ret 0) nodefault)
+ (error "`cargo locate-project' returned %s status: %s" ret (buffer-string)))
+ ((and (/= ret 0) (not nodefault))
+ (setq rustic--buffer-workspace default-directory))
+ (t
+ (goto-char 0)
+ (let* ((output (json-read))
+ (dir (file-name-directory (cdr (assoc-string "root" output)))))
+ (setq rustic--buffer-workspace dir))))))))
(defun rustic-buffer-crate (&optional nodefault)
"Return the crate for the current buffer.
diff --git a/test/rustic-cargo-test.el b/test/rustic-cargo-test.el
index a026511..18158ae 100644
--- a/test/rustic-cargo-test.el
+++ b/test/rustic-cargo-test.el
@@ -352,7 +352,7 @@ fn test2() {
(proc-buf (process-buffer proc)))
(while (eq (process-status proc) 'run)
(sit-for 0.1)))
- (let* ((proc (rustic-cargo-test-rerun nil))
+ (let* ((proc (rustic-cargo-test-rerun))
(proc-buf (process-buffer proc)))
(while (eq (process-status proc) 'run)
(sit-for 0.1))
diff --git a/test/rustic-compile-test.el b/test/rustic-compile-test.el
index 1ba9cbb..4a5c656 100644
--- a/test/rustic-compile-test.el
+++ b/test/rustic-compile-test.el
@@ -91,7 +91,7 @@
(while (eq (process-status proc) 'run)
(sit-for 0.1))
(should (string= compilation-directory dir))
- (let ((proc (rustic-recompile nil)))
+ (let ((proc (rustic-recompile)))
(while (eq (process-status proc) 'run)
(sit-for 0.1)))
(should (string= (car compilation-arguments) "cargo fmt"))
@@ -108,7 +108,7 @@
(while (eq (process-status proc) 'run)
(sit-for 0.1))
(should (string= compilation-directory dir))
- (let ((proc (rustic-recompile nil)))
+ (let ((proc (rustic-recompile)))
(while (eq (process-status proc) 'run)
(sit-for 0.1)))
(should (string= (car compilation-arguments) "cargo build"))
@@ -127,7 +127,7 @@
(while (eq (process-status proc) 'run)
(sit-for 0.01))
(should (= 0 (process-exit-status proc)))
- (let ((p (rustic-recompile nil)))
+ (let ((p (rustic-recompile)))
(while (eq (process-status proc) 'run)
(sit-for 0.1))
(should (= 0 (process-exit-status p))))))))