Commit f7a3b15e authored by Sebastian Wiesner's avatar Sebastian Wiesner

Add Flycheck Buttercup with custom Buttercup matchers

parent 2fecfc64
......@@ -19,6 +19,8 @@ now for questions and discussions about development. [GH-820]
configuration file [GH-846]
* Add `flycheck-puppet-lint-disabled-checks` to disable specific checks of
puppetlint [GH-824]
* New library `flycheck-buttercup` to support writing [Buttercup][] specs for
* Improvements:
......@@ -35,6 +37,8 @@ now for questions and discussions about development. [GH-820]
* Work around a caching issue in Rubocop [GH-844]
* Fix checkdoc failure with some Emacs Lisp syntax [GH-833] [GH-845]
## 0.25.1 (Nov 16, 2015) ##
* Fix undefined function call in `emacs-lisp` syntax checker [GH-791]
......@@ -3,7 +3,7 @@
(package-file "flycheck.el")
(files "flycheck.el" "flycheck-ert.el"
(files "flycheck.el" "flycheck-ert.el" "flycheck-buttercup.el"
;; Cask automatically builds docs for us :)
......@@ -34,7 +34,7 @@ def emacs_batch(*args)
[ENV['EMACS'] || 'emacs', '-Q', '--batch'] + args
SOURCES = FileList['flycheck.el', 'flycheck-ert.el']
SOURCES = FileList['flycheck.el', 'flycheck-ert.el', 'flycheck-buttercup.el']
OBJECTS = SOURCES.ext('.elc')
DOC_SOURCES = FileList['doc/flycheck.texi']
......@@ -168,7 +168,7 @@ end
namespace :test do
desc 'Run specs'
task :specs, [:pattern] => OBJECTS do |_, args|
command = ['cask', 'exec', 'buttercup', '-L', '.', '-L', 'test/lib']
command = ['cask', 'exec', 'buttercup', '-L', '.']
command += ['--pattern', args.pattern] if args.pattern
;;; flycheck-buttercup.el --- Flycheck: Extensions to Buttercup -*- lexical-binding: t; -*-
;; Copyright (C) 2016 Sebastian Wiesner and Flycheck contributors
;; Author: Sebastian Wiesner <>
;; Keywords: lisp, tools
;; 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
;; 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 <>.
;;; Commentary:
;; Extensions to Buttercup to write BDD tests for Flycheck.
;; Buttercup is a BDD testing framework for Emacs, see URL
;; `'. Flycheck uses
;; Buttercup extensively for new tests.
;; This library provides extensions to Buttercup to write Specs for Flycheck.
;; * Custom matchers
;; (expect 'foo :to-be-local) - Is `foo' a local variable in the current buffer?
;;; Code:
(require 'buttercup)
(require 'flycheck)
(require 'seq)
(defun flycheck-buttercup-format-error-list (errors)
"Format ERRORS into a human-readable string."
(mapconcat (lambda (e) (flycheck-error-format e 'with-file-name))
errors "\n"))
;;; Custom matchers
(buttercup-define-matcher :to-be-local (symbol)
(if (local-variable-p symbol)
(cons t (format "Expected %S not to be a local variable, but it is" symbol))
(cons nil (format "Expected %S to be a local variable, but it is not" symbol))))
(buttercup-define-matcher :to-be-empty-string (s)
(if (equal s "")
(cons t (format "Expected %S not be an empty string" s))
(cons nil (format "Expected %S to be an empty string" s))))
(buttercup-define-matcher :to-be-equal-flycheck-errors (a b)
(let ((a-formatted (flycheck-buttercup-format-error-list a))
(b-formatted (flycheck-buttercup-format-error-list b)))
(if (equal a b)
(cons t (format "Expected
not to be equal to
%s" a-formatted b-formatted))
(cons nil (format "Expected
to be equal to
%s" a-formatted b-formatted)))))
(provide 'flycheck-buttercup)
;;; flycheck-buttercup.el ends here
......@@ -25,8 +25,7 @@
;;; Code:
(require 'flycheck)
(require 'buttercup)
(require 'flycheck-buttercup)
(require 'cl-lib)
(require 'seq)
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