diff options
Diffstat (limited to 'lib/prog')
| -rw-r--r-- | lib/prog/jao-rust.el | 20 |
1 files changed, 15 insertions, 5 deletions
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") |
