emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/d-mode 576dd29 123/346: tests: Actually test compilation-m


From: ELPA Syncer
Subject: [nongnu] elpa/d-mode 576dd29 123/346: tests: Actually test compilation-mode error list correctness
Date: Sun, 29 Aug 2021 11:00:15 -0400 (EDT)

branch: elpa/d-mode
commit 576dd294747136a96b47397531505acd4aa423d6
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>

    tests: Actually test compilation-mode error list correctness
    
    Previously, the test file (I0069.txt) was usable only for manual testing.
    Now, compilation-mode correctness can be tested with "make test".
---
 d-mode-test.el  | 15 +++++++++++++++
 tests/I0069.txt |  3 +++
 2 files changed, 18 insertions(+)

diff --git a/d-mode-test.el b/d-mode-test.el
index d61a759..51fe53d 100644
--- a/d-mode-test.el
+++ b/d-mode-test.el
@@ -210,11 +210,26 @@
       (kill-test-buffer))
     (not error-found)))
 
+(defun d-test-get-compilation-lines ()
+  "Get list of line numbers of lines recognized as errors by 
`compilation-mode'.
+
+Called from the #run snippet of individual test files."
+  (compilation-mode)
+  (let (buffer-read-only)
+    (compilation-parse-errors (point-min) (point-max)))
+  (let (error-list)
+    (while (condition-case nil
+              (progn (compilation-next-error 1) t)
+            (error nil))
+      (setq error-list (cons (line-number-at-pos) error-list)))
+    (reverse error-list)))
+
 ;; Run the tests
 (ert-deftest d-mode-basic ()
   (should (equal (do-one-test "tests/I0021.d") t))
   (should (equal (do-one-test "tests/I0039.d") t))
   (should (equal (do-one-test "tests/I0064.d") t))
+  (should (equal (do-one-test "tests/I0069.txt") t))
   )
 
 ;;----------------------------------------------------------------------------
diff --git a/tests/I0069.txt b/tests/I0069.txt
index 959feac..9e066f8 100644
--- a/tests/I0069.txt
+++ b/tests/I0069.txt
@@ -1,5 +1,8 @@
 -*-compilation-*-
 
+// #run: (d-test-get-compilation-lines)
+// #out: (6 7 9 10 13)
+
 foo.d(1): Error: Test error
 foo.d(1,1): Error: Column number test
 baz.d(3,4):        instantiated from here: Continuation test



reply via email to

[Prev in Thread] Current Thread [Next in Thread]