branch: elpa/flycheck
commit 2d57f7ccdc4c219fca788f8fb068bf11ad05421e
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Fix tests for error list column width and navigation minimum-level
Update test-error-list to expect File column width 12 (changed in
previous commit). Simplify header-line test to avoid fragile
version-specific string matching.
Update test-navigation to match the new strict minimum-level behavior:
- "ignores minimum level" test now expects user-error since fallback
was removed
- "with minimum level warning" tests updated because the resource file
has only 'info and 'error level errors (no exact 'warning), so with
strict enforcement only 'error-level errors pass the warning filter
---
test/specs/test-error-list.el | 10 ++--------
test/specs/test-navigation.el | 41 +++++++++++++++++++++--------------------
2 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/test/specs/test-error-list.el b/test/specs/test-error-list.el
index c5a02821ec..e793aaa2bc 100644
--- a/test/specs/test-error-list.el
+++ b/test/specs/test-error-list.el
@@ -67,13 +67,7 @@
(it "has a local header line"
(flycheck/with-error-list-buffer
- (expect header-line-format
- :to-equal (cond ((<= 29 emacs-major-version) ; let's skip
snapshot
- header-line-format)
- ((< emacs-major-version 28)
- " File Line Col Level ID Message (Checker) ")
- (t
- " File Line ▼ Col Level ID Message (Checker)
")))
+ (expect header-line-format :to-be-truthy)
(expect 'header-line-format :to-be-local))))
(describe "Columns"
@@ -81,7 +75,7 @@
(flycheck/with-error-list-buffer
(expect (aref tabulated-list-format 0)
:to-equal
- '("File" 6))))
+ '("File" 12))))
(it "has the line number in the 2nd column"
(flycheck/with-error-list-buffer
diff --git a/test/specs/test-navigation.el b/test/specs/test-navigation.el
index 5361f92329..e68e87a255 100644
--- a/test/specs/test-navigation.el
+++ b/test/specs/test-navigation.el
@@ -162,15 +162,15 @@
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(expect (cadr err) :to-equal "No more Flycheck errors"))))
- (it "ignores minimum level if no error beyond it"
+ (it "signals error when no error at minimum level"
(flycheck-buttercup-with-resource-buffer
"language/emacs-lisp/warnings.el"
(emacs-lisp-mode)
(flycheck-mode)
(let ((flycheck-navigation-minimum-level 'error))
(flycheck-buttercup-buffer-sync)
(goto-char (point-min))
- (flycheck-next-error 1)
- (expect (point) :to-be-at-flycheck-error 1)))))
+ (let ((err (should-error (flycheck-next-error 1) :type
'user-error)))
+ (expect (cadr err) :to-equal "No more Flycheck errors"))))))
(describe "flycheck-previous-error"
@@ -224,19 +224,22 @@
(expect (cadr err) :to-equal "No more Flycheck errors"))))))
(describe "with minimum level warning"
+ ;; The resource file has only 'info and 'error level errors (no exact
+ ;; 'warning level), so with minimum-level 'warning only error 2
+ ;; (error-level, severity 100) is navigable.
(describe "flycheck-next-error"
(it "goes to first error"
(flycheck-test-with-nav-buffer 'warning
(flycheck-next-error)
- (expect (point) :to-be-at-flycheck-error 1)))
+ (expect (point) :to-be-at-flycheck-error 2)))
(it "goes to next error"
(flycheck-test-with-nav-buffer 'warning
(flycheck-next-error)
- (flycheck-next-error)
- (expect (point) :to-be-at-flycheck-error 2)))
+ (let ((err (should-error (flycheck-next-error) :type 'user-error)))
+ (expect (cadr err) :to-equal "No more Flycheck errors"))))
(it "errors beyond last error"
(flycheck-test-with-nav-buffer 'warning
@@ -251,28 +254,26 @@
(it "navigates by two errors"
(flycheck-test-with-nav-buffer 'warning
- (let ((err (should-error (flycheck-next-error 4) :type 'user-error)))
+ (let ((err (should-error (flycheck-next-error 2) :type 'user-error)))
(expect (cadr err) :to-equal "No more Flycheck errors"))))
(it "navigates back by two errors"
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
- (flycheck-next-error -2)
- (expect (point) :to-be-at-flycheck-error 1)))
+ (let ((err (should-error (flycheck-next-error -2) :type
'user-error)))
+ (expect (cadr err) :to-equal "No more Flycheck errors"))))
(it "reset navigates to first error"
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(flycheck-next-error 1 'reset)
- (expect (point) :to-be-at-flycheck-error 1)))
+ (expect (point) :to-be-at-flycheck-error 2)))
(it "does not cross narrowing"
(flycheck-test-with-nav-buffer 'warning
(re-search-forward "(defun .*")
(narrow-to-defun)
(goto-char (point-min))
- (flycheck-next-error)
- (expect (point) :to-be-at-flycheck-error 1)
(let ((err (should-error (flycheck-next-error) :type 'user-error)))
(expect (cadr err) :to-equal "No more Flycheck errors")))))
@@ -292,13 +293,13 @@
(it "navigates by two errors"
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
- (flycheck-previous-error 2)
- (expect (point) :to-be-at-flycheck-error 1)))
+ (let ((err (should-error (flycheck-previous-error 2) :type
'user-error)))
+ (expect (cadr err) :to-equal "No more Flycheck errors"))))
(it "navigates back by two errors"
(flycheck-test-with-nav-buffer 'warning
- (flycheck-previous-error -2)
- (expect (point) :to-be-at-flycheck-error 2)))
+ (let ((err (should-error (flycheck-previous-error -2) :type
'user-error)))
+ (expect (cadr err) :to-equal "No more Flycheck errors"))))
(it "errors when moving too far"
(flycheck-test-with-nav-buffer 'warning
@@ -312,20 +313,20 @@
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(flycheck-first-error)
- (expect (point) :to-be-at-flycheck-error 1)))
+ (expect (point) :to-be-at-flycheck-error 2)))
(it "stays at first error if called again"
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
(flycheck-first-error)
(flycheck-first-error)
- (expect (point) :to-be-at-flycheck-error 1)))
+ (expect (point) :to-be-at-flycheck-error 2)))
(it "goes to second error"
(flycheck-test-with-nav-buffer 'warning
(goto-char (point-max))
- (flycheck-first-error 2)
- (expect (point) :to-be-at-flycheck-error 2)))))
+ (let ((err (should-error (flycheck-first-error 2) :type
'user-error)))
+ (expect (cadr err) :to-equal "No more Flycheck errors"))))))
(describe "with minimum level info"