File: test-executables.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 (79 lines) | stat: -rw-r--r-- 3,976 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
;;; test-executables.el --- Flycheck Specs: Executables -*- lexical-binding: t; -*-

;;; Code:

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

(describe "Executables of command checkers"

  (describe "flycheck-overridden-executable"

    (it "uses overridden executable"
      (let ((flycheck-emacs-lisp-executable (flycheck-buttercup-resource-filename
                                             "bin/dummy-emacs")))
        (when (eq system-type 'darwin)
          (buttercup-skip "Skipped because macOS will take forever to complete the task"))
        (when (eq system-type 'windows-nt)
          (buttercup-skip "Skipped on Windows due to platform-specific checker differences"))
        (flycheck-buttercup-should-syntax-check
         "language/emacs-lisp/warnings.el" 'emacs-lisp-mode
         '(12 nil info "First sentence should end with punctuation"
              :checker emacs-lisp-checkdoc)
         '(17 4 error "t is not true!" :checker emacs-lisp)
         '(19 11 warning "This is a stupid message" :checker emacs-lisp)))))

  (describe "flycheck-set-checker-executable"

    (it "real executable"
      (assume (not (eq system-type 'windows-nt)))
      (flycheck-buttercup-with-temp-buffer
        ;; Create a temporary buffer to restrict the scope of
        ;; `flycheck-emacs-lisp-executable'
        (let ((file-name (flycheck-buttercup-resource-filename "bin/dummy-emacs")))
          (expect (file-exists-p file-name) :to-be-truthy)
          (expect (file-executable-p file-name) :to-be-truthy)
          (expect (local-variable-p 'flycheck-emacs-lisp-executable) :not :to-be-truthy)
          (with-no-warnings
            (flycheck-set-checker-executable 'emacs-lisp file-name))
          (expect (local-variable-p 'flycheck-emacs-lisp-executable) :to-be-truthy)
          (expect flycheck-emacs-lisp-executable :to-equal file-name)))
      ;; The global value should remain unaffected
      (expect flycheck-emacs-lisp-executable :not :to-be-truthy))

    (it "no executable given"
      (flycheck-buttercup-with-temp-buffer
        (let ((file-name (flycheck-buttercup-resource-filename "bin/dummy-emacs")))
          (setq-local flycheck-emacs-lisp-executable file-name)
          (expect flycheck-emacs-lisp-executable :to-equal file-name)
          (with-no-warnings
            (flycheck-set-checker-executable 'emacs-lisp))
          (expect flycheck-emacs-lisp-executable :not :to-be-truthy)
          (expect (local-variable-p 'flycheck-emacs-lisp-executable) :to-be-truthy))))

    (it "executable is nil"
      (flycheck-buttercup-with-temp-buffer
        (let ((file-name (flycheck-buttercup-resource-filename "bin/dummy-emacs")))
          (setq-local flycheck-emacs-lisp-executable file-name)
          (expect flycheck-emacs-lisp-executable :to-equal file-name)
          (with-no-warnings
            (flycheck-set-checker-executable 'emacs-lisp nil))
          (expect flycheck-emacs-lisp-executable :not :to-be-truthy)
          (expect (local-variable-p 'flycheck-emacs-lisp-executable) :to-be-truthy))))

    (it "non-existing file"
      (let ((file-name (flycheck-buttercup-resource-filename "no-such-file")))
        (expect (file-exists-p file-name) :not :to-be-truthy)
        (let ((err (should-error (flycheck-set-checker-executable
                                  'emacs-lisp file-name) :type 'user-error)))
          (expect (cadr err) :to-equal (format "%s is no executable" file-name)))))

    (it "file not executable"
      (let ((file-name (flycheck-buttercup-resource-filename "language/emacs-lisp/warnings.el")))
        (expect (file-exists-p file-name) :to-be-truthy)
        (expect (file-executable-p file-name) :not :to-be-truthy)
        (let ((err (should-error (flycheck-set-checker-executable
                                  'emacs-lisp file-name) :type 'user-error)))
          (expect (cadr err) :to-equal (format "%s is no executable" file-name)))))))

;;; test-executables.el ends here