Commit f6b1594c authored by Sebastian Wiesner's avatar Sebastian Wiesner

Port tests for manual to buttercup

parent 7c534308
......@@ -8,6 +8,7 @@
"doc/flycheck.texi")
(development
(depends-on "buttercup") ; BDD test framework for Emacs
(depends-on "shut-up") ; Silence Emacs
;; Various modes for use in the unit tests
......
......@@ -150,6 +150,13 @@ namespace :compile do
end
namespace :test do
desc 'Run specs'
task :specs, [:pattern] => OBJECTS do |_, args|
command = ['cask', 'exec', 'buttercup', '-L', '.', '-L', 'test/lib']
command += ['--pattern', args.pattern] if args.pattern
sh(*command)
end
desc 'Run unit test suite'
task :unit, [:selector] => OBJECTS do |_, args|
test_args = args.selector ? [args.selector] : []
......@@ -166,7 +173,7 @@ namespace :test do
end
desc 'Run all tests'
task all: [:unit, :html]
task all: [:specs, :unit, :html]
end
namespace :doc do
......
......@@ -149,67 +149,6 @@ and extension, as in `file-name-base'."
(flycheck-test-def-untabified-test "admin/run-checkdoc.el")
;;; Manual
(ert-deftest flycheck--manual/all-checkers-are-documented ()
:tags '(documentation)
(flycheck-ert-with-file-buffer
(expand-file-name "doc/languages.texi"
flycheck-test-source-directory)
(let ((expected-checkers flycheck-checkers)
documented-checkers)
(while (re-search-forward (rx "@flyc{" (group (1+ (not (any "}")))) "}")
nil 'noerror)
(let ((checker (intern (match-string 1))))
(unless (memq checker documented-checkers)
(push checker documented-checkers))))
(setq documented-checkers (nreverse documented-checkers))
(dolist (checker documented-checkers)
(let ((expected (pop expected-checkers)))
(should (equal checker expected)))))))
(ert-deftest flycheck--manual/all-options-are-documented ()
:tags '(documentation)
(let ((options (sort (-uniq
(apply #'append
(mapcar (lambda (c)
(flycheck-checker-get c 'option-vars))
flycheck-checkers)))
#'string<))
(filename (expand-file-name "doc/languages.texi"
flycheck-test-source-directory))
documented-options)
(flycheck-ert-with-file-buffer filename
(while (re-search-forward (rx line-start "@flycoption" (opt "x") (1+ space)
(group (1+ not-newline)) line-end)
nil 'no-error)
(push (match-string 1) documented-options)))
(setq documented-options (sort documented-options #'string<))
(dolist (option documented-options)
(let ((expected (pop options)))
(should (equal (intern option) expected))))))
(ert-deftest flycheck--manual/all-config-file-vars-are-documented ()
:tags '(documentation)
(let ((config-file-vars (sort
(delq
nil
(mapcar (lambda (c)
(flycheck-checker-get c 'config-file-var))
flycheck-checkers))
#'string<))
documented-config-files)
(flycheck-ert-with-file-buffer
(expand-file-name "doc/languages.texi" flycheck-test-source-directory)
(while (re-search-forward (rx line-start "@flycconfigfile{"
(group (1+ (not (any "," "}")))) ",")
nil 'noerror)
(push (match-string 1) documented-config-files)))
(setq documented-config-files (sort documented-config-files #'string<))
(dolist (config-file documented-config-files)
(let ((expected (pop config-file-vars)))
(should (equal (intern config-file) expected))))))
;;; Customization
(ert-deftest flycheck-checkers/there-are-registered-checkers ()
:tags '(customization)
......
;;; test-documentation.el --- Flycheck: Specs for documentation -*- lexical-binding: t; -*-
;; Copyright (C) 2013-2016 Sebastian Wiesner and Flycheck contributors
;; Author: Sebastian Wiesner <swiesner@lunaryorn.com>
;; This file is not part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'flycheck)
(require 'buttercup)
(require 'cl-lib)
(require 'seq)
(describe "Manual"
(let* ((source-dir (locate-dominating-file default-directory "Cask"))
(languages (expand-file-name "doc/languages.texi" source-dir)))
(defun flycheck/collect-languages (pattern)
"Collect all PATTERN matches from the list of languages."
(let ((matches))
(with-temp-buffer
(insert-file-contents languages)
(goto-char (point-min))
(while (re-search-forward pattern nil 'noerror)
(let ((match (intern (match-string 1))))
(cl-pushnew match matches))))
matches))
(it "should document all syntax checkers"
(let ((checkers (flycheck/collect-languages
(rx "@flyc{" (group (1+ (not (any "}")))) "}"))))
(expect (seq-difference checkers flycheck-checkers)
:not :to-be-truthy)
(expect (seq-difference flycheck-checkers checkers)
:not :to-be-truthy)))
(it "should document all options"
(let ((documented-options (flycheck/collect-languages
(rx line-start "@flycoption"
(opt "x") (1+ space)
(group (1+ not-newline)) line-end)))
(all-options (seq-mapcat (lambda (c)
(flycheck-checker-get c 'option-vars))
flycheck-checkers)))
(expect (seq-difference documented-options all-options)
:not :to-be-truthy)
(expect (seq-difference all-options documented-options)
:not :to-be-truthy))))
(it "should document all configuration file variables"
(let ((documented-file-vars (flycheck/collect-languages
(rx line-start "@flycconfigfile{"
(group (1+ (not (any "," "}")))) ",")))
(all-file-vars (delq nil
(seq-map (lambda (c)
(flycheck-checker-get
c 'config-file-var))
flycheck-checkers))))
(expect (seq-difference documented-file-vars all-file-vars)
:not :to-be-truthy)
(expect (seq-difference all-file-vars documented-file-vars)
:not :to-be-truthy))))
;;; test-documentation.el ends here
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment