diff options
| author | jao <jao@gnu.org> | 2026-03-10 10:22:26 +0000 |
|---|---|---|
| committer | jao <jao@gnu.org> | 2026-03-25 23:45:20 +0000 |
| commit | 5c11fc1947560a1535cf093e1fbab241b4412a97 (patch) | |
| tree | 94e645a9554d85b64bfe2122fbf4384a055b2373 /lib/prog | |
| parent | 637f6c752e109fe31ca42aaf4bb84bc95d695653 (diff) | |
| download | elibs-5c11fc1947560a1535cf093e1fbab241b4412a97.tar.gz elibs-5c11fc1947560a1535cf093e1fbab241b4412a97.tar.bz2 | |
more on rust tests
Diffstat (limited to 'lib/prog')
| -rw-r--r-- | lib/prog/jao-rust.el | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/prog/jao-rust.el b/lib/prog/jao-rust.el index 9c08e9b..fdc6b0d 100644 --- a/lib/prog/jao-rust.el +++ b/lib/prog/jao-rust.el @@ -40,14 +40,36 @@ (replace-regexp-in-string "/\\(mod\\|lib\\|main\\)$" "") (string-replace "/" "::")))) +(defconst jao-rust--test-header-rx + (concat "#\\[" (regexp-opt '("test" "quickcheck" "tokio::test") t))) + +(defconst jao-rust--test-name-rx "^ *\\(pub\\)?\\( async\\)? fn \\([^(]+\\)(") + +(defun jao-rust-test-at-point () + (when (looking-at jao-rust--test-name-rx) (match-string-no-properties 3))) + +(defun jao-rust-test-before-point () + (save-excursion + (when (re-search-backward jao-rust--test-header-rx nil t) + (forward-line) + (jao-rust-test-at-point)))) + +(defun jao-rust-test-current () + (interactive) + (if-let* ((m (jao-rust-current-module-name)) + (n (jao-rust-test-before-point))) + (let ((rustic-test-arguments (format "-- --exact %s::tests::%s" m n)) + (rustic-cargo-use-last-stored-arguments t)) + (rustic-cargo-test)) + (message "No test before point"))) + (defun jao-rust-buffer-tests () (save-excursion (goto-char (point-min)) (let ((res '())) - (while (re-search-forward "#\\[\\(tokio::test\\|test\\|quickcheck\\)" nil t) + (while (re-search-forward jao-rust--test-header-rx nil t) (forward-line) - (when (looking-at "^ *\\(pub\\)?\\( async\\)? fn \\([^(]+\\)(") - (push (match-string-no-properties 3) res))) + (when-let* ((name (jao-rust-test-at-point))) (push name res))) res))) (defun jao-rust-test-module () @@ -57,7 +79,8 @@ (messages "No tests in this module") (let* ((mod (jao-rust-current-module-name)) (tests (mapconcat (lambda (x) (format "%s::tests::%s" mod x)) tests " ")) - (rustic-test-arguments (format "-- --exact %s" tests))) + (rustic-test-arguments (format "-- --exact %s" tests)) + (rustic-cargo-use-last-stored-arguments t)) (rustic-cargo-test))))) (defun jao-rust-test-workspace () |
