summaryrefslogtreecommitdiff
path: root/rust-cargo-tests.el
diff options
context:
space:
mode:
authorSibi Prabakaran <sibi@psibi.in>2024-09-03 18:03:45 +0530
committerGitHub <noreply@github.com>2024-09-03 18:03:45 +0530
commitc87f6f82bd484fb1c15009c8a3518ebb62942605 (patch)
treead38072cdd12fc5ea5e58d26463c631798fbf1d3 /rust-cargo-tests.el
parent4686c6e5f5042cb2c692f022afc4d170d344deda (diff)
parent19199f6c4addcc74f7c14deef153f12c1e006cf1 (diff)
downloadrust-mode-c87f6f82bd484fb1c15009c8a3518ebb62942605.tar.gz
Merge pull request #556 from roife/rustfmt-compilation-mode
introduce a new compilation-mode for rust-format
Diffstat (limited to 'rust-cargo-tests.el')
-rw-r--r--rust-cargo-tests.el19
1 files changed, 19 insertions, 0 deletions
diff --git a/rust-cargo-tests.el b/rust-cargo-tests.el
index f49cba0..fe78ac7 100644
--- a/rust-cargo-tests.el
+++ b/rust-cargo-tests.el
@@ -1,5 +1,6 @@
;;; rust-cargo-tests.el --- ERT tests for rust-cargo.el -*- lexical-binding: t; -*-
(require 'rust-cargo)
+(require 'rust-rustfmt)
(require 'ert)
(defun rust-test--wait-process-exit ()
@@ -51,3 +52,21 @@
(rust-test--send-process-string "1234\n")
(rust-test--wait-process-exit)
(should (rust-test--find-string "***run interactive: 1234")))))
+
+(ert-deftest rust-test-rustfmt ()
+ (skip-unless (executable-find "rustfmt"))
+ (rust-test--with-main-file-buffer
+ (let ((old-content (buffer-string))
+ (ret (rust-format-buffer)))
+ (should (string= ret "Formatted buffer with rustfmt."))
+ (should (string= old-content (buffer-string))))))
+
+(ert-deftest rust-test-rustfmt-parsing-errors ()
+ (skip-unless (executable-find "rustfmt"))
+ (with-temp-buffer
+ (insert "fn main() {")
+ (rust-format-buffer)
+ (with-current-buffer "*rustfmt*"
+ (should (eq major-mode 'rust-format-mode))
+ (should (rust-test--find-string "error:")))
+ (kill-buffer "*rustfmt*")))