contrib/hg-test-mode.el
changeset 41788 19979b8b87e2
parent 41786 b6c062bb4be3
child 46819 d4ba4d51f85f
--- a/contrib/hg-test-mode.el	Thu Feb 21 23:06:18 2019 -0500
+++ b/contrib/hg-test-mode.el	Thu Feb 21 23:07:54 2019 -0500
@@ -65,4 +65,33 @@
                  "\\+  \\([^:\n]+\\):\\([0-9]+\\):$" 1 2))
   (add-to-list 'compilation-error-regexp-alist 'hg-test-check-code-output))
 
+(defun hg-test-mode--test-one-error-line-regexp (test)
+  (erase-buffer)
+  (setq compilation-locs (make-hash-table))
+  (insert (car test))
+  (compilation-parse-errors (point-min) (point-max))
+  (let ((msg (get-text-property 1 'compilation-message)))
+    (should msg)
+    (let ((loc (compilation--message->loc msg))
+          (line (nth 1 test))
+          (file (nth 2 test)))
+      (should (equal (compilation--loc->line loc) line))
+      (should (equal (caar (compilation--loc->file-struct loc)) file)))
+      msg))
+
+(require 'ert)
+(ert-deftest hg-test-mode--compilation-mode-support ()
+  "Test hg-specific compilation-mode regular expressions"
+  (require 'compile)
+  (with-temp-buffer
+    (font-lock-mode -1)
+    (mapc 'hg-test-mode--test-one-error-line-regexp
+          '(
+            ("+  contrib/debugshell.py:37:" 37 "contrib/debugshell.py")
+            ("+    File \"/tmp/hg/mercurial/commands.py\", line 3115, in help_"
+             3115 "/tmp/hg/mercurial/commands.py")
+            ("+    File \"mercurial/dispatch.py\", line 225, in dispatch"
+             225 "mercurial/dispatch.py")))))
+
+
 (provide 'hg-test-mode)