branch: elpa/d-mode
commit 576dd294747136a96b47397531505acd4aa423d6
Author: Vladimir Panteleev <[email protected]>
Commit: Vladimir Panteleev <[email protected]>
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