Patchwork D6003: tests: add test for hg-test-mode emacs code

login
register
mail settings
Submitter phabricator
Date Feb. 25, 2019, 1:38 a.m.
Message ID <e41c8a581ad5445ce672fefb330f0c36@localhost.localdomain>
Download mbox | patch
Permalink /patch/38921/
State Not Applicable
Headers show

Comments

phabricator - Feb. 25, 2019, 1:38 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG19979b8b87e2: tests: add test for hg-test-mode emacs code (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6003?vs=14186&id=14231

REVISION DETAIL
  https://phab.mercurial-scm.org/D6003

AFFECTED FILES
  contrib/hg-test-mode.el
  tests/test-contrib-emacs.t

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-contrib-emacs.t b/tests/test-contrib-emacs.t
new file mode 100644
--- /dev/null
+++ b/tests/test-contrib-emacs.t
@@ -0,0 +1,8 @@ 
+#require emacs
+  $ emacs -q -no-site-file -batch -l $TESTDIR/../contrib/hg-test-mode.el \
+  >  -f ert-run-tests-batch-and-exit
+  Running 1 tests (*) (glob)
+     passed  1/1  hg-test-mode--compilation-mode-support
+  
+  Ran 1 tests, 1 results as expected (*) (glob)
+  
diff --git a/contrib/hg-test-mode.el b/contrib/hg-test-mode.el
--- a/contrib/hg-test-mode.el
+++ b/contrib/hg-test-mode.el
@@ -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)