File: test-error-display.el

package info (click to toggle)
flycheck 36.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,600 kB
  • sloc: lisp: 16,210; python: 718; makefile: 219; cpp: 24; ruby: 23; perl: 21; ada: 17; f90: 16; haskell: 15; javascript: 15; sh: 14; erlang: 14; xml: 14; ansic: 12; php: 9; tcl: 8; fortran: 3; vhdl: 2; awk: 1; sql: 1
file content (60 lines) | stat: -rw-r--r-- 2,596 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
;;; test-error-display.el --- Flycheck Specs: Error Display -*- lexical-binding: t; -*-

;;; Code:

(require 'flycheck-buttercup)
(require 'test-helpers)
(require 'shut-up)

(describe "Error display"

  (describe "flycheck-display-errors-function"

    (it "no display function set"
      (let ((err (flycheck-error-new-at 10 20 'warning "This is a Flycheck error."))
            (flycheck-display-errors-function nil))
        (shut-up
          ;; Without an error function, error display should be a no-op.
          (flycheck-display-errors (list err))
          (expect (shut-up-current-output) :to-equal ""))))

    (it "custom function"
      (let* ((err (flycheck-error-new-at 10 20 'warning "Foo"))
             (displayed-errors nil)
             (flycheck-display-errors-function (lambda (errors)
                                                 (dolist (err errors)
                                                   (push err displayed-errors)))))
        (flycheck-display-errors (list err))
        (expect displayed-errors :to-equal (list err)))))

  ;; (describe "flycheck-display-error-messages"

  ;;   (it "displays error messages"
  ;;     (assume (not (eq system-type 'windows-nt)))
  ;;     (let ((err (flycheck-error-new-at 10 20 'warning
  ;;                                       "This is a Flycheck error."
  ;;                                       :id "spam")))
  ;;       (shut-up
  ;;         (flycheck-display-error-messages (list err))
  ;;         (expect (shut-up-current-output)
  ;;                 :to-equal "This is a Flycheck error. [spam]\n")))))

  (describe "flycheck-copy-errors-as-kill"

    (it "copies errors to kill ring"
      (flycheck-buttercup-with-temp-buffer
        (insert "A test buffer to copy errors from")
        (let ((flycheck-highlighting-mode 'columns) ; Disable Sexps parsing
              (errors (list (flycheck-error-new-at 1 nil 'error "1st message")
                            (flycheck-error-new-at 1 10 'warning "2nd message"
                                                   :id "foo"))))
          (mapc #'flycheck-add-overlay errors)
          (flycheck-copy-errors-as-kill 10)
          (expect (seq-take kill-ring 2) :to-equal '("1st message" "2nd message"))
          (flycheck-copy-errors-as-kill 10 #'flycheck-error-id)
          (expect (seq-take kill-ring 1) :to-equal '("foo"))
          (flycheck-copy-errors-as-kill 10 #'flycheck-error-format-message-and-id)
          (expect (seq-take kill-ring 2)
                  :to-equal '("1st message" "2nd message [foo]")))))))

;;; test-error-display.el ends here