branch: externals/matlab-mode
commit 4e81ea9b82d0b6e8597cf5538e9ab094bbe71c65
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>

    t-utils: added ability to disable line-by-line indent sub-test
---
 tests/t-utils.el                                   | 47 +++++++++++++---------
 .../indent_comment_fcn.m                           |  3 ++
 .../indent_comment_fcn.skip.typing.txt             |  1 -
 .../indent_comment_fcn_expected.m                  |  3 ++
 4 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/tests/t-utils.el b/tests/t-utils.el
index 5cbb9585da..29a60c2e13 100644
--- a/tests/t-utils.el
+++ b/tests/t-utils.el
@@ -1054,7 +1054,7 @@ See `t-utils-test-indent' for LINE-MANIPULATOR."
             (write-region typing-got nil typing-got-file)
             (setq error-msg
                   (list
-                   (format "Indenting-unidented-contents-of: %s" lang-file)
+                   (format "Indenting-unindented-contents-of: %s" lang-file)
                    (format "Got: %s" typing-got-file)
                    (format "Expected: %s" expected-file)))))
         ;; result is nil or an error message list of strings
@@ -1152,9 +1152,9 @@ Two methods are used to indent each file in LANG-FILES,
 
  3. Indent the contents of lang-file line-by-line when there are no
     error nodes in lang-file.  In a temporary buffer
-      - Insert the string-trim'd line of lang-file
+      - Insert the string-trim'd first line of lang-file
       - RET to indent via `newline'
-      - Repeat for each line of lang-file.
+      - Repeat for each remaining line of lang-file.
     Validate result matches the EXPECTED.
 
     If the test fails, a file named NAME_typing_line_by_line.LANG~ is
@@ -1170,6 +1170,11 @@ Two methods are used to indent each file in LANG-FILES,
     file as to why it's skipped
       .../tests/test-LANGUAGE-ts-mode-indent-files/indent_fcn.skip.typing.txt
 
+    If it is not possible to indent the file line-by-line, you can disable
+    the line-by-line indent without generating a warning by adding in a
+    comment to lang-file:
+      t-utils-test-indent: no-line-by-line-indent - <REASON>
+
 Example test setup:
 
   ./LANGUAGE-ts-mode.el
@@ -1223,6 +1228,7 @@ To debug a specific indent test file
                          (with-temp-buffer
                            (insert-file-contents-literally expected-file)
                            (buffer-string))))
+             do-line-by-line-indent
              lang-file-major-mode
              error-node)
 
@@ -1244,6 +1250,10 @@ To debug a specific indent test file
             (t-utils--trim)
             (let ((got (buffer-substring (point-min) (point-max)))
                   (got-file (concat expected-file "~")))
+
+              (setq do-line-by-line-indent
+                    (not (string-match-p "t-utils-test-indent:[ 
\t]*no-line-by-line-indent" got)))
+
               (set-buffer-modified-p nil)
               (kill-buffer)
 
@@ -1267,21 +1277,22 @@ To debug a specific indent test file
             (when unindented-error-msg
               (push unindented-error-msg error-msgs)))
 
-          (let ((skip-typing-file (replace-regexp-in-string "\\.[^.]\\'" 
".skip.typing.txt"
-                                                            lang-file)))
-            (if (file-exists-p skip-typing-file)
-                (t-utils--skip-message lang-file skip-typing-file
-                                       "typing line-by-line this test input")
-              (message "START: %s <indent-via-typing-line-by-line> %s" 
test-name lang-file)
-              (let ((start-time (current-time))
-                    (typing-error-msg (t-utils--test-indent-typing-line-by-line
-                                       lang-file lang-file-major-mode
-                                       expected expected-file)))
-                (message "%s: %s <indent-via-typing-line-by-line> %s %s" 
test-name lang-file
-                         (if typing-error-msg "FAIL" "PASS")
-                         (t-utils--took start-time))
-                (when typing-error-msg
-                  (push typing-error-msg error-msgs)))))
+          (when do-line-by-line-indent
+            (let ((skip-typing-file (replace-regexp-in-string "\\.[^.]\\'" 
".skip.typing.txt"
+                                                              lang-file)))
+              (if (file-exists-p skip-typing-file)
+                  (t-utils--skip-message lang-file skip-typing-file
+                                         "typing line-by-line this test input")
+                (message "START: %s <indent-via-typing-line-by-line> %s" 
test-name lang-file)
+                (let ((start-time (current-time))
+                      (typing-error-msg 
(t-utils--test-indent-typing-line-by-line
+                                         lang-file lang-file-major-mode
+                                         expected expected-file)))
+                  (message "%s: %s <indent-via-typing-line-by-line> %s %s" 
test-name lang-file
+                           (if typing-error-msg "FAIL" "PASS")
+                           (t-utils--took start-time))
+                  (when typing-error-msg
+                    (push typing-error-msg error-msgs))))))
           )
         ))
     ;; Validate t-utils-test-indent result
diff --git a/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn.m 
b/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn.m
index 895c7aa2bc..e2368ed4ec 100644
--- a/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn.m
+++ b/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn.m
@@ -1,4 +1,7 @@
 % -*- matlab-ts -*-
+%
+% t-utils-test-indent: no-line-by-line-indent - nested functions require an end
+
 function indent_comment_fcn
 % This is the
 % doc help comment
diff --git 
a/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn.skip.typing.txt 
b/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn.skip.typing.txt
deleted file mode 100644
index c73ba6717e..0000000000
--- a/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn.skip.typing.txt
+++ /dev/null
@@ -1 +0,0 @@
-Some items not indented correctly.
diff --git 
a/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn_expected.m 
b/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn_expected.m
index 01ac656985..71a1e51db5 100644
--- a/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn_expected.m
+++ b/tests/test-matlab-ts-mode-indent-files/indent_comment_fcn_expected.m
@@ -1,4 +1,7 @@
 % -*- matlab-ts -*-
+%
+% t-utils-test-indent: no-line-by-line-indent - nested functions require an end
+
 function indent_comment_fcn
 % This is the
 % doc help comment

Reply via email to