diff options
| author | roife <roifewu@gmail.com> | 2024-09-03 04:05:40 +0800 |
|---|---|---|
| committer | roife <roifewu@gmail.com> | 2024-09-03 04:06:37 +0800 |
| commit | b385ea062674dc0ba4ca4ef426b243136527c6dc (patch) | |
| tree | bcf186fccae8523b4f227edf1b374afb72a3bbe3 | |
| parent | 4e7bf14bd074925b5f7b233a0f47b7a5ce4790ae (diff) | |
| download | rust-mode-b385ea062674dc0ba4ca4ef426b243136527c6dc.tar.gz | |
tests: add tests for rust-format
| -rw-r--r-- | rust-cargo-tests.el | 19 |
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*"))) |
