summaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/rust-cargo-tests.el
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d/lisp/rust-cargo-tests.el')
-rw-r--r--.emacs.d/lisp/rust-cargo-tests.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/.emacs.d/lisp/rust-cargo-tests.el b/.emacs.d/lisp/rust-cargo-tests.el
index fe78ac7..1b072ee 100644
--- a/.emacs.d/lisp/rust-cargo-tests.el
+++ b/.emacs.d/lisp/rust-cargo-tests.el
@@ -21,6 +21,13 @@
21 (find-file main-file) 21 (find-file main-file)
22 ,expr))) 22 ,expr)))
23 23
24(defmacro rust-test--with-snippet-buffer (expr)
25 `(let* ((test-dir (expand-file-name "test-project/" default-directory))
26 (snippet-file (expand-file-name "src/rustfmt-default.rs" test-dir)))
27 (save-current-buffer
28 (find-file snippet-file)
29 ,expr)))
30
24(defun rust-test--find-string (string) 31(defun rust-test--find-string (string)
25 "Find STRING in current buffer." 32 "Find STRING in current buffer."
26 (goto-char (point-min)) 33 (goto-char (point-min))
@@ -70,3 +77,13 @@
70 (should (eq major-mode 'rust-format-mode)) 77 (should (eq major-mode 'rust-format-mode))
71 (should (rust-test--find-string "error:"))) 78 (should (rust-test--find-string "error:")))
72 (kill-buffer "*rustfmt*"))) 79 (kill-buffer "*rustfmt*")))
80
81(ert-deftest rust-test-respect-rustfmt-defaults ()
82 (skip-unless (executable-find "rustfmt"))
83 (rust-test--with-snippet-buffer
84 (let ((old-content (buffer-string))
85 (ret (rust-format-buffer)))
86 (should (string= old-content (buffer-string))))))
87
88(ert-deftest rust-test-ensure-rustfmt-switches-nil ()
89 (should (eq rust-rustfmt-switches nil)))