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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
;;; test-configuration.el --- Flycheck Specs: Configuration -*- lexical-binding: t; -*-
;;; Code:
(require 'flycheck-buttercup)
(require 'test-helpers)
(describe "Configuration files and options"
(describe "flycheck-locate-config-file-by-path"
(it "just a base name"
(flycheck-buttercup-with-temp-buffer
(cd flycheck-test-directory)
(expect (flycheck-locate-config-file-by-path "init.el"
'emacs-lisp)
:not :to-be-truthy)))
(it "with path"
(flycheck-buttercup-with-temp-buffer
(cd flycheck-test-directory)
(expect (flycheck-locate-config-file-by-path "../Makefile"
'emacs-lisp)
:to-equal (expand-file-name "../Makefile" flycheck-test-directory))))
(it "non-existing file"
(flycheck-buttercup-with-temp-buffer
(cd flycheck-test-directory)
(expect (flycheck-locate-config-file-by-path "../foobar" 'emacs-lisp)
:not :to-be-truthy))))
(describe "flycheck-locate-config-file-ancestor-directories"
(it "not existing file"
(flycheck-buttercup-with-temp-buffer
(setq buffer-file-name (expand-file-name "init.el"
flycheck-test-directory))
(expect (flycheck-locate-config-file-ancestor-directories
"foo" 'emacs-lisp)
:not :to-be-truthy)))
(it "file on same level"
(flycheck-buttercup-with-temp-buffer
(setq buffer-file-name (expand-file-name "test-helpers.el"
flycheck-test-specs-directory))
(expect (flycheck-locate-config-file-ancestor-directories
"test-documentation.el" 'emacs-lisp)
:to-equal (expand-file-name "test-documentation.el"
flycheck-test-specs-directory))))
(it "file on parent level"
(flycheck-buttercup-with-temp-buffer
(setq buffer-file-name (expand-file-name "init.el"
flycheck-test-directory))
(expect (flycheck-locate-config-file-ancestor-directories
"Makefile" 'emacs-lisp)
:to-equal (expand-file-name "../Makefile"
flycheck-test-directory)))))
(describe "flycheck-locate-config-file-home"
(it "not existing file"
(flycheck-buttercup-with-env (list (cons "HOME" flycheck-test-directory))
(expect (flycheck-locate-config-file-home "foo" 'emacs-lisp)
:not :to-be-truthy)))
(it "existing file in parent directory"
(flycheck-buttercup-with-env (list (cons "HOME" flycheck-test-directory))
(expect (flycheck-locate-config-file-home "Makefile" 'emacs-lisp)
:not :to-be-truthy)))
(it "existing file in home directory"
(flycheck-buttercup-with-env (list (cons "HOME" flycheck-test-directory))
(expect (flycheck-locate-config-file-home
"init.el" 'emacs-lisp)
:to-equal (expand-file-name "init.el"
flycheck-test-directory)))))
(describe "flycheck-locate-config-file"
(it "multiple files"
(flycheck-buttercup-with-temp-buffer
(setq buffer-file-name (expand-file-name "specs/test-documentation.el"
flycheck-test-directory))
(expect (flycheck-locate-config-file
'("test-documentation.el" "no-such-file.el") 'emacs-lisp)
:to-equal (expand-file-name "specs/test-documentation.el"
flycheck-test-directory))))
(it "multiple files ordered"
(flycheck-buttercup-with-temp-buffer
(setq buffer-file-name (expand-file-name "specs/test-documentation.el"
flycheck-test-directory))
(expect (flycheck-locate-config-file
'("init.el" "test-documentation.el") 'emacs-lisp)
:to-equal (expand-file-name "init.el" flycheck-test-directory)))))
(describe "flycheck-option-int"
(it "pass through nil"
(expect (flycheck-option-int nil) :not :to-be-truthy))
(it "integer argument"
(expect (flycheck-option-int 10) :to-equal "10")))
(describe "flycheck-option-comma-separated-list"
(it "empty list"
(expect (flycheck-option-comma-separated-list nil) :not :to-be-truthy))
(it "with single nil"
(expect (flycheck-option-comma-separated-list '(nil)) :not :to-be-truthy))
(it "filter returns nil"
(expect (flycheck-option-comma-separated-list '(10 20) nil
(lambda (_x) nil))
:not :to-be-truthy))
(it "default separator"
(expect (flycheck-option-comma-separated-list '("foo" "bar"))
:to-equal "foo,bar"))
(it "custom separator"
(expect (flycheck-option-comma-separated-list '("foo" "bar") ":")
:to-equal "foo:bar"))
(it "custom filter"
(expect (flycheck-option-comma-separated-list '(10 20) nil
#'number-to-string)
:to-equal "10,20"))))
;;; test-configuration.el ends here
|