[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 0c0ec7dbd6 281/500: ert/indent: Add macro to easi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 0c0ec7dbd6 281/500: ert/indent: Add macro to easily test indentation |
Date: |
Sat, 29 Jan 2022 08:27:14 -0500 (EST) |
branch: elpa/nix-mode
commit 0c0ec7dbd66c6f39d65a91d169e25fb03de0fa5c
Author: Elis Hirwing <elis@hirwing.se>
Commit: Elis Hirwing <elis@hirwing.se>
ert/indent: Add macro to easily test indentation
---
tests/nix-mode-tests.el | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/tests/nix-mode-tests.el b/tests/nix-mode-tests.el
index d92a02fef5..4ed5208c29 100644
--- a/tests/nix-mode-tests.el
+++ b/tests/nix-mode-tests.el
@@ -4,6 +4,7 @@
;;; Code:
+(require 'cl-lib)
(require 'ert)
(require 'nix-mode)
@@ -26,5 +27,48 @@
(nix-mode)
(eq (nix--get-string-type (nix--get-parse-state (point))) nil))))
+;;; Indentation tests
+
+(defvar nix-mode-test-dir (expand-file-name "testcases"
+ (if load-file-name
+ (file-name-directory
load-file-name)
+ default-directory))
+ "Directory containing the `nix-mode' testcase files.")
+
+;; Define macro to build indentation tests
+(cl-defmacro with-nix-mode-test ((file &key indent) &rest body)
+ "Set up environment for testing `nix-mode'.
+Execute BODY in a temporary buffer containing the contents of
+FILE, in `nix-mode'. All tests will use the `nix-indent-line'
+function to do the indentation tests."
+
+ `(with-temp-buffer
+ ;; Read test data file
+ (insert-file-contents (expand-file-name ,file nix-mode-test-dir))
+
+ ;; Store the file as a local variable and set the right indentation
function to use
+ (let ((raw-file (buffer-substring-no-properties (point-min) (point-max)))
+ (nix-indent-function 'nix-indent-line)
+ (inhibit-message t))
+ ;; Load up nix-mode
+ (nix-mode)
+
+ ;; If we're doing an indentation test
+ (if ,indent
+ (progn
+ ;; Indent the buffer
+ (indent-region (point-min) (point-max))
+
+ ;; Compare buffer to the stored buffer contents
+ (should (equal
+ (buffer-substring-no-properties (point-min) (point-max))
+ raw-file))))
+
+ ;; Go to beginning
+ (goto-char (point-min))
+
+ ;; Run additional tests
+ ,@body)))
+
(provide 'nix-mode-tests)
;;; nix-mode-tests.el ends here
- [nongnu] elpa/nix-mode c462eb400b 251/500: Add alias for nix-repl-show, (continued)
- [nongnu] elpa/nix-mode c462eb400b 251/500: Add alias for nix-repl-show, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 47cdb44e2e 255/500: Improve indentation robustness, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1c772ad539 253/500: Remove recommended config, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 295cd6729b 261/500: Add nix-edit.el, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode fde8c8e38c 268/500: Merge pull request #48 from dustinlacewell/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 90ac0a74b2 273/500: Merge pull request #55 from teozkr/issue-54, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 563f6bdb03 272/500: Fixed `nix-mode-comments` matching everything, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode abdeae0f23 276/500: Make sure nix-instantiate-executable exists before running it, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 57ea981cb2 278/500: Use eval-when-compile for subr-x, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1512d02830 279/500: Formatting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0c0ec7dbd6 281/500: ert/indent: Add macro to easily test indentation,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 7f968e8a7f 284/500: Merge pull request #61 from etu/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4ac7b5afb6 287/500: Add indent region function, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ff0a773d31 297/500: fix-issue-72: Check the correct element from syntax-ppss, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1798168074 307/500: Use nix-indent-function when setting indent-line-function., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 022fac17a6 308/500: Un-delete nix-indent-line., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1cda7dabbc 309/500: Bug fix: replace memq with member, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4016a1c89b 321/500: Release 1.4.0, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 91834848b4 320/500: Generate AUTHORS.md, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0bab799a87 325/500: Add failing test that checks indentation of closing parens., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode dd5f937a49 331/500: Change the description of a couple of tests., ELPA Syncer, 2022/01/29