Skip to content

Commit b385ea0

Browse files
committed
tests: add tests for rust-format
1 parent 4e7bf14 commit b385ea0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Diff for: rust-cargo-tests.el

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
;;; rust-cargo-tests.el --- ERT tests for rust-cargo.el -*- lexical-binding: t; -*-
22
(require 'rust-cargo)
3+
(require 'rust-rustfmt)
34
(require 'ert)
45

56
(defun rust-test--wait-process-exit ()
@@ -51,3 +52,21 @@
5152
(rust-test--send-process-string "1234\n")
5253
(rust-test--wait-process-exit)
5354
(should (rust-test--find-string "***run interactive: 1234")))))
55+
56+
(ert-deftest rust-test-rustfmt ()
57+
(skip-unless (executable-find "rustfmt"))
58+
(rust-test--with-main-file-buffer
59+
(let ((old-content (buffer-string))
60+
(ret (rust-format-buffer)))
61+
(should (string= ret "Formatted buffer with rustfmt."))
62+
(should (string= old-content (buffer-string))))))
63+
64+
(ert-deftest rust-test-rustfmt-parsing-errors ()
65+
(skip-unless (executable-find "rustfmt"))
66+
(with-temp-buffer
67+
(insert "fn main() {")
68+
(rust-format-buffer)
69+
(with-current-buffer "*rustfmt*"
70+
(should (eq major-mode 'rust-format-mode))
71+
(should (rust-test--find-string "error:")))
72+
(kill-buffer "*rustfmt*")))

0 commit comments

Comments
 (0)