From e7a033d37898567915d41266daa903b3c48a11f5 Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 25 Jun 2026 14:15:58 +0100 Subject: python and rust tweaks --- lib/prog/jao-rust.el | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'lib/prog') diff --git a/lib/prog/jao-rust.el b/lib/prog/jao-rust.el index 2281875..b2549ab 100644 --- a/lib/prog/jao-rust.el +++ b/lib/prog/jao-rust.el @@ -39,13 +39,14 @@ rel (replace-regexp-in-string "^src\\(/bin\\)?/" "") (string-replace "-" "_") - (replace-regexp-in-string "/\\(mod\\|lib\\|main\\)$" "") + (replace-regexp-in-string "\\(^\\|/\\)\\(mod\\|lib\\|main\\)$" "") (string-replace "/" "::"))))) (defun jao-rust--tests-prefix () - (if-let* ((m (jao-rust-current-module-name))) - (concat m "::tests::") - "")) + (let ((m (jao-rust-current-module-name))) + (cond ((not (stringp m)) "") + ((string-empty-p m) "tests::") + (t (concat m "::tests::"))))) (defconst jao-rust--test-header-rx (concat "#\\[" (regexp-opt '("test" "quickcheck" "tokio::test") t))) @@ -98,13 +99,22 @@ (interactive) (let ((tests (jao-rust-buffer-tests))) (if (seq-empty-p tests) - (message "No tests in this module") + (when (y-or-n-p "No tests in this module. Run doc tests?") + (jao-rust-test-doctests)) (let* ((prefix (jao-rust--tests-prefix)) (tests (mapconcat (lambda (x) (format "%s%s" prefix x)) tests " ")) (rustic-test-arguments (format "-- --exact %s" tests)) (rustic-cargo-use-last-stored-arguments t)) (rustic-cargo-test))))) +(defun jao-rust-test-doctests (&optional all) + (interactive "P") + (let* ((m (if all "" (jao-rust-current-module-name))) + (rustic-cargo-test-runner 'cargo) + (rustic-test-arguments (format "--doc %s" m)) + (rustic-cargo-use-last-stored-arguments t)) + (rustic-cargo-test))) + (defun jao-rust-retest () (interactive) (let* ((rustic-test-arguments "-R latest") -- cgit v1.2.3