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

    skip indent_xr_for_within_case.m on Windows
    
    On Windows,
      tests/test-matlab-ts-mode-indent-xr-files/indent_xr_for_within_case.m
    passes when run interactively via
      M-x ert
      test-matlab-ts-mode-indent-xr
    but fails when run via make (batch emacs).
---
 tests/t-utils.el                                   | 30 ++++++++++++++++++++--
 .../indent_xr_for_within_case.skip.txt             |  7 +++++
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/tests/t-utils.el b/tests/t-utils.el
index 6a1ab9909f..3f22a3c48d 100644
--- a/tests/t-utils.el
+++ b/tests/t-utils.el
@@ -82,6 +82,14 @@
 ;;          ./tests/test-NAME-files/test_file3_expected.EXT
 ;;          ./tests/test-NAME-files/test_file3.skip.txt       // content says 
why test is disabled
 ;;
+;;      If you want the *.skip.txt to only apply on a given system type, you 
add to it's contents
+;;         skip-system-type: <value>
+;;      The value to place is (symbol-name system-type).  This field can be 
repeated.  For example,
+;;      if a test fails on Windows and Mac, but passes elsewhere, you would 
add to *.skip.txt
+;;      contents:
+;;         skip-system-type: windows-nt
+;;         skip-system-type: darwin
+;;
 ;;   4. Execute-and-record tests
 ;;
 ;;      Within your ./tests/test-NAME-files/test_file1.lang you can place in 
comments
@@ -287,6 +295,16 @@ Optional TEST-DESCRIPTION defaults to \"this test input\"."
     (message "%s:1: warning: skipping %s because %s exists\n%s"
              test-file (or test-description "this test input") skip-file 
skip-file-contents)))
 
+(defun t-utils--skip-test-case (skip-file)
+  "Does SKIP-FILE say to skip the test case?
+See `t-utils-get-files' for details."
+  (with-temp-buffer
+    (insert-file-contents-literally skip-file)
+    (goto-char (point-min))
+    (if (re-search-forward "^[ \t]*skip-system-type:[ \t]*\\([-a-z0-9_]+\\)" 
nil t)
+        t
+      (goto-char (point-min))
+      (not (re-search-forward "^[ \t]*skip-system-type:" nil t)))))
 
 (defun t-utils-get-files (test-name base-regexp &optional skip-regexp 
file-to-use)
   "Return list of test input files, /abs/path/to/TEST-NAME-files/FILE.LANG.
@@ -296,7 +314,14 @@ file and the result is a list of one file.
 
 For each:   /abs/path/to/TEST-NAME-files/FILE.LANG
 if exists:  /abs/path/to/TEST-NAME-files/FILE.skip.txt
-then this test input file is skipped.
+then this test input file is skipped if the contents do not contain
+  skip-system-type: <value>
+or the contents contain
+  skip-system-type: <value>
+and value matches (symbol-name `system-type').  For example,
+to skip a test case on Windows and Mac you would add to *.skip.txt
+  skip-system-type: windows-nt
+  skip-system-type: darwin
 
 TEST-NAME is used to locate the TEST-NAME-files directory.
 
@@ -328,7 +353,8 @@ skipping all *_expected.lang files."
     (let ((files-not-skipped '()))
       (dolist (file files)
         (let ((skip-file (replace-regexp-in-string "\\.[^.]\\'" ".skip.txt" 
file)))
-          (if (file-exists-p skip-file)
+          (if (and (file-exists-p skip-file)
+                   (t-utils--skip-test-case skip-file))
               (t-utils--skip-message file skip-file)
             ;; Not skipped. Note we ignore hidden link files, e.g. .#foo.lang
             (when (not (string-match-p "\\`\\.#" file))
diff --git 
a/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_for_within_case.skip.txt 
b/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_for_within_case.skip.txt
new file mode 100644
index 0000000000..03617dbcef
--- /dev/null
+++ 
b/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_for_within_case.skip.txt
@@ -0,0 +1,7 @@
+skip-system-type: windows-nt
+  On Windows,
+    tests/test-matlab-ts-mode-indent-xr-files/indent_xr_for_within_case.m
+  passes when run interactively via
+    M-x ert
+    test-matlab-ts-mode-indent-xr
+  but fails when run via make (batch emacs).

Reply via email to