[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/bnf-mode 05287d9 11/36: Merge pull request #12 from ser
From: |
Stefan Monnier |
Subject: |
[elpa] externals/bnf-mode 05287d9 11/36: Merge pull request #12 from sergeyklay/feature/buttercup |
Date: |
Wed, 17 Mar 2021 18:40:15 -0400 (EDT) |
branch: externals/bnf-mode
commit 05287d97de41ee33953a9f3570bcd33054d1100f
Merge: 8799c4a d697e0a
Author: Serghei Iakovlev <sergeyklay@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Merge pull request #12 from sergeyklay/feature/buttercup
Migrate tests to use buttercup
---
Cask | 3 +-
Makefile | 2 +-
NEWS | 6 ++
default.mk | 2 +-
test/bnf-mode-font-test.el | 170 --------------------------------------
test/test-bnf-mode-font-lock.el | 165 ++++++++++++++++++++++++++++++++++++
test/{test-helper.el => utils.el} | 22 ++---
7 files changed, 182 insertions(+), 188 deletions(-)
diff --git a/Cask b/Cask
index 7261a35..d926bdc 100644
--- a/Cask
+++ b/Cask
@@ -10,7 +10,6 @@
(depends-on "cl-lib" "0.5")
(development
- (depends-on "s")
(depends-on "f")
- (depends-on "ert-runner")
+ (depends-on "buttercup")
(depends-on "undercover"))
diff --git a/Makefile b/Makefile
index 0f58703..1704b98 100644
--- a/Makefile
+++ b/Makefile
@@ -72,7 +72,7 @@ build: $(OBJS)
.PHONY: test
test:
- @$(CASK) exec ert-runner $(TESTFLAGS)
+ @$(CASK) exec buttercup $(TESTFLAGS)
.PHONY: clean
clean:
diff --git a/NEWS b/NEWS
index 1e60807..2cc33d1 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,12 @@ Copyright (C) 2019, 2020 Free Software Foundation, Inc.
See the end of the file for license conditions.
This file is about changes in BNF Mode.
+* Unreleased
+** Migrate tests from ert-runner to buttercup
+Previously BNF Mode used ert through ert-runner for testing
+purposes. However, it seems ert-runner is abandoned (the last
+commit a few years ago), it still uses only Emacs 24 on its own
+tests and in general it looks as not maintained anymore project.
* BNF Mode 0.4.4
** Rework documentation and provide Info-file.
diff --git a/default.mk b/default.mk
index b5ed03b..ae4310c 100644
--- a/default.mk
+++ b/default.mk
@@ -26,7 +26,7 @@ INSTALL_INFO ?= $(shell command -v ginstall-info || printf
install-info)
MAKEINFO ?= makeinfo
EMACSFLAGS ?=
-TESTFLAGS ?= --reporter ert+duration
+TESTFLAGS ?= -L .
PANDOCLAGS ?= --fail-if-warnings \
--reference-links \
--atx-headers \
diff --git a/test/bnf-mode-font-test.el b/test/bnf-mode-font-test.el
deleted file mode 100644
index 3d99c35..0000000
--- a/test/bnf-mode-font-test.el
+++ /dev/null
@@ -1,170 +0,0 @@
-;;; bnf-mode-font-test.el --- BNF Mode: Font highlighting test suite -*-
lexical-binding: t; -*-
-
-;; Copyright (C) 2019, 2020 Free Software Foundation, Inc.
-
-;; Author: Serghei Iakovlev <egrep@protonmail.ch>
-;; Maintainer: Serghei Iakovlev <egrep@protonmail.ch>
-;; Version: 0.4.4
-;; URL: https://github.com/sergeyklay/bnf-mode
-
-;;;; License
-
-;; This file 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 file 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 file. If not, see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; Automate tests from the "test" directory using `ert', which comes bundled
-;; with Emacs >= 24.1.
-
-;;; Code:
-
-
-;;;; Font locking
-
-(ert-deftest bnf-mode-syntax-table/fontify-strings ()
- :tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer
- "<string delimers> ::= \" | ' | ` | ”"
- (should-not (bnf-test-face-at 23))
- (should-not (bnf-test-face-at 27))
- (should-not (bnf-test-face-at 31))
- (should-not (bnf-test-face-at 35))))
-
-(ert-deftest bnf-mode-syntax-table/fontify-line-comments ()
- :tags '(fontification syntax-table)
- (custom-set-variables '(bnf-mode-algol-comments-style nil))
- (bnf-test-with-temp-buffer
- "; A
-
-<stm> ::= <decl> ; foo"
- (should (eq (bnf-test-face-at 1) 'font-lock-comment-delimiter-face))
- (should (eq (bnf-test-face-at 3) 'font-lock-comment-face))
- (should-not (bnf-test-face-at 5))
- (should (eq (bnf-test-face-at 24) 'font-lock-comment-face))))
-
-;; TODO
-(ert-deftest bnf-mode-syntax-table/fontify-algol-comments ()
- :tags '(fontification syntax-table)
- (custom-set-variables '(bnf-mode-algol-comments-style t))
- (bnf-test-with-temp-buffer "" ))
-
-(ert-deftest bnf-mode-syntax-table/fontify-nonterminals ()
- :tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer
- "<stm> ::= <decl>
-angle-brackets ::= are-optional"
- ;; angle bracket
- (should-not (bnf-test-face-at 1))
- ;; "stm"
- (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 4) 'font-lock-function-name-face))
- ;; angle bracket
- (should-not (bnf-test-face-at 5))
- ;; "::=" symbol
- (should (eq (bnf-test-face-at 7) 'font-lock-constant-face))
- (should (eq (bnf-test-face-at 9) 'font-lock-constant-face))
- ;; angle bracket
- (should-not (bnf-test-face-at 11))
- ;; "dec" symbol
- (should (eq (bnf-test-face-at 12) 'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 15) 'font-lock-builtin-face))))
-
-(ert-deftest bnf-mode-syntax-table/fontify-nonterminals-case ()
- :tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer
- "<RULE> ::= <foo>
-<RuLe> ::= <foO>"
- (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face))
- (should-not (bnf-test-face-at 17))
- (should (eq (bnf-test-face-at 19) 'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 22) 'font-lock-function-name-face))
- (should-not (bnf-test-face-at 23))
- (should (eq (bnf-test-face-at 30) 'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 32) 'font-lock-builtin-face))
- (should-not (bnf-test-face-at 33))))
-
-(ert-deftest bnf-mode-syntax-table/fontify-nonterminals-start-pos ()
- :tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer
- " <rule> ::= <foo>"
- (should-not (bnf-test-face-at 4))
- (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 6) 'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 7) 'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 8) 'font-lock-function-name-face))
- (should-not (bnf-test-face-at 9))))
-
-(ert-deftest bnf-mode-syntax-table/fontify-sequence ()
- :tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer
- "<rule> ::= <foo> <bar> <baz>"
- ;; "<" angle bracket
- (should-not (bnf-test-face-at 1))
- ;; "rule"
- (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face))
- ;; ">" angle bracket
- (should-not (bnf-test-face-at 6))
- ;; "foo"
- (should (eq (bnf-test-face-at 13) 'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 15) 'font-lock-builtin-face))
- ;; space
- (should-not (bnf-test-face-at 17))
- ;; "bar"
- (should (eq (bnf-test-face-at 19) 'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 21) 'font-lock-builtin-face))
- ;; space
- (should-not (bnf-test-face-at 23))
- ;; "baz"
- (should (eq (bnf-test-face-at 25) 'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 27) 'font-lock-builtin-face))))
-
-(ert-deftest bnf-mode-syntax-table/fontify-alternatives ()
- :tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer
- "<foo> | <bar> | <baz>"
- ;; "foo"
- (should (eq (bnf-test-face-at 2) 'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 4) 'font-lock-builtin-face))
- ;; "|"
- (should (eq (bnf-test-face-at 7) 'font-lock-warning-face))
- ;; "bar"
- (should (eq (bnf-test-face-at 10) 'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 12) 'font-lock-builtin-face))
- ;; "|"
- (should (eq (bnf-test-face-at 15) 'font-lock-warning-face))
- ;; "baz"
- (should (eq (bnf-test-face-at 18) 'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 20) 'font-lock-builtin-face))))
-
-(ert-deftest bnf-mode-syntax-table/fontify-rule-punctuation ()
- :tags '(fontification syntax-table)
- (bnf-test-with-temp-buffer
- "
-<proper string> ::=
- <any sequence of symbols not containing ` or ' >
- | <empty>"
- ;; "proper string"
- (should (eq (bnf-test-face-at 3) 'font-lock-function-name-face))
- (should (eq (bnf-test-face-at 15) 'font-lock-function-name-face))
- ;; "any sequence of symbols not containing ` or ' "
- (should (eq (bnf-test-face-at 31) 'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 76) 'font-lock-builtin-face))
- ;; "empty"
- (should (eq (bnf-test-face-at 90) 'font-lock-builtin-face))
- (should (eq (bnf-test-face-at 94) 'font-lock-builtin-face))))
-
-(provide 'bnf-mode-font-test)
-;;; bnf-mode-font-test.el ends here
diff --git a/test/test-bnf-mode-font-lock.el b/test/test-bnf-mode-font-lock.el
new file mode 100644
index 0000000..2bdb38b
--- /dev/null
+++ b/test/test-bnf-mode-font-lock.el
@@ -0,0 +1,165 @@
+;;; test-bnf-mode-font-lock.el --- BNF Mode: Font locking tests -*-
lexical-binding: t; -*-
+
+;; Copyright (C) 2019, 2020 Free Software Foundation, Inc.
+
+;; Author: Serghei Iakovlev <egrep@protonmail.ch>
+;; Maintainer: Serghei Iakovlev <egrep@protonmail.ch>
+;; Version: 0.4.4
+;; URL: https://github.com/sergeyklay/bnf-mode
+
+;;;; License
+
+;; This file 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 file 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 file. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Define test-suites to test `bnf-mode' font locking using `buttercup'.
+
+;;; Code:
+
+(require 'buttercup)
+(load (concat (file-name-directory (or load-file-name (buffer-file-name)
+ default-directory))
+ "utils.el") nil 'nomessage 'nosuffix)
+
+
+;;;; Tests
+
+(describe "BNF Fontification"
+ (it "does not fontify strings"
+ (bnf-test-with-temp-buffer
+ "<string delimers> ::= \" | ' | ` | ”"
+ (should-not (bnf-test-face-at 23))
+ (should-not (bnf-test-face-at 27))
+ (should-not (bnf-test-face-at 31))
+ (should-not (bnf-test-face-at 35))))
+
+ (it "fontify line comments"
+ (custom-set-variables '(bnf-mode-algol-comments-style nil))
+ (bnf-test-with-temp-buffer
+ "; A
+
+<stm> ::= <decl> ; foo"
+ (should (eq (bnf-test-face-at 1) 'font-lock-comment-delimiter-face))
+ (should (eq (bnf-test-face-at 3) 'font-lock-comment-face))
+ (should-not (bnf-test-face-at 5))
+ (should (eq (bnf-test-face-at 24) 'font-lock-comment-face))))
+
+ ;; TODO(sergei): Implement me
+ (it "fontify ALGOL comments"
+ (custom-set-variables '(bnf-mode-algol-comments-style t))
+ (bnf-test-with-temp-buffer "" ))
+
+ (it "fontify nonterminals"
+ (bnf-test-with-temp-buffer
+ "<stm> ::= <decl>
+angle-brackets ::= are-optional"
+ ;; angle bracket
+ (should-not (bnf-test-face-at 1))
+ ;; "stm"
+ (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 4) 'font-lock-function-name-face))
+ ;; angle bracket
+ (should-not (bnf-test-face-at 5))
+ ;; "::=" symbol
+ (should (eq (bnf-test-face-at 7) 'font-lock-constant-face))
+ (should (eq (bnf-test-face-at 9) 'font-lock-constant-face))
+ ;; angle bracket
+ (should-not (bnf-test-face-at 11))
+ ;; "dec" symbol
+ (should (eq (bnf-test-face-at 12) 'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 15) 'font-lock-builtin-face))))
+
+ (it "fontify nonterminals despite the case"
+ (bnf-test-with-temp-buffer
+ "<RULE> ::= <foo>
+<RuLe> ::= <foO>"
+ (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face))
+ (should-not (bnf-test-face-at 17))
+ (should (eq (bnf-test-face-at 19) 'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 22) 'font-lock-function-name-face))
+ (should-not (bnf-test-face-at 23))
+ (should (eq (bnf-test-face-at 30) 'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 32) 'font-lock-builtin-face))
+ (should-not (bnf-test-face-at 33))))
+
+ (it "fontify nonterminals despite the indentation"
+ (bnf-test-with-temp-buffer
+ " <rule> ::= <foo>"
+ (should-not (bnf-test-face-at 4))
+ (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 6) 'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 7) 'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 8) 'font-lock-function-name-face))
+ (should-not (bnf-test-face-at 9))))
+
+ (it "fontify sequences"
+ (bnf-test-with-temp-buffer
+ "<rule> ::= <foo> <bar> <baz>"
+ ;; "<" angle bracket
+ (should-not (bnf-test-face-at 1))
+ ;; "rule"
+ (should (eq (bnf-test-face-at 2) 'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 5) 'font-lock-function-name-face))
+ ;; ">" angle bracket
+ (should-not (bnf-test-face-at 6))
+ ;; "foo"
+ (should (eq (bnf-test-face-at 13) 'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 15) 'font-lock-builtin-face))
+ ;; space
+ (should-not (bnf-test-face-at 17))
+ ;; "bar"
+ (should (eq (bnf-test-face-at 19) 'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 21) 'font-lock-builtin-face))
+ ;; space
+ (should-not (bnf-test-face-at 23))
+ ;; "baz"
+ (should (eq (bnf-test-face-at 25) 'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 27) 'font-lock-builtin-face))))
+
+ (it "fontify alternatives"
+ (bnf-test-with-temp-buffer
+ "<foo> | <bar> | <baz>"
+ ;; "foo"
+ (should (eq (bnf-test-face-at 2) 'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 4) 'font-lock-builtin-face))
+ ;; "|"
+ (should (eq (bnf-test-face-at 7) 'font-lock-warning-face))
+ ;; "bar"
+ (should (eq (bnf-test-face-at 10) 'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 12) 'font-lock-builtin-face))
+ ;; "|"
+ (should (eq (bnf-test-face-at 15) 'font-lock-warning-face))
+ ;; "baz"
+ (should (eq (bnf-test-face-at 18) 'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 20) 'font-lock-builtin-face))))
+
+ (it "fontify rule punctuation"
+ (bnf-test-with-temp-buffer
+ "
+<proper string> ::=
+ <any sequence of symbols not containing ` or ' >
+ | <empty>"
+ ;; "proper string"
+ (should (eq (bnf-test-face-at 3) 'font-lock-function-name-face))
+ (should (eq (bnf-test-face-at 15) 'font-lock-function-name-face))
+ ;; "any sequence of symbols not containing ` or ' "
+ (should (eq (bnf-test-face-at 31) 'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 76) 'font-lock-builtin-face))
+ ;; "empty"
+ (should (eq (bnf-test-face-at 90) 'font-lock-builtin-face))
+ (should (eq (bnf-test-face-at 94) 'font-lock-builtin-face)))))
+
+;;; test-bnf-mode-font-lock.el ends here
diff --git a/test/test-helper.el b/test/utils.el
similarity index 86%
rename from test/test-helper.el
rename to test/utils.el
index f63ea72..e4e7f94 100644
--- a/test/test-helper.el
+++ b/test/utils.el
@@ -1,4 +1,4 @@
-;;; test-helper.el --- BNF Mode: Non-interactive unit-test setup -*-
lexical-binding: t; -*-
+;;; utils.el --- BNF Mode: Non-interactive unit-test setup -*-
lexical-binding: t; -*-
;; Copyright (C) 2019, 2020 Free Software Foundation, Inc
@@ -28,8 +28,8 @@
;;; Code:
-(require 's) ; `s-contains?'
-(require 'cl-lib) ; `cl-defmacro'
+(require 'buttercup)
+(require 'cl-lib) ; `cl-defmacro'
;; Make sure the exact Emacs version can be found in the build output
(message "Running tests on Emacs %s" emacs-version)
@@ -60,16 +60,18 @@
`(with-temp-buffer
(insert ,content)
(bnf-mode)
+
,(if (fboundp 'font-lock-ensure)
'(font-lock-ensure)
'(with-no-warnings (font-lock-fontify-buffer)))
+ (pop-to-buffer (current-buffer))
(goto-char (point-min))
- ,@body))
+ (unwind-protect
+ (progn ,@body))))
(defun bnf-test-face-at (pos &optional content)
"Get the face at POS in CONTENT.
-
If CONTENT is not given, return the face at POS in the current
buffer."
(if content
@@ -77,12 +79,4 @@ buffer."
(get-text-property pos 'face))
(get-text-property pos 'face)))
-(when (s-contains? "--win" (getenv "ERT_RUNNER_ARGS"))
- (defun ert-runner/run-tests-batch-and-exit (selector)
- (ert-run-tests-interactively selector)))
-
-;; Local Variables:
-;; indent-tabs-mode: nil
-;; End:
-
-;;; test-helper.el ends here
+;;; utils.el ends here
- [elpa] externals/bnf-mode updated (4a7aff6 -> d88eef6), Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 3f8062e 01/36: Amended documentation, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 9c8c27e 02/36: Update copyright notice to follow common form, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 45834dc 03/36: Add file test/.nosearch, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 046d2e7 04/36: Added .gitattributes file, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode cd9082a 05/36: Rearrange Makefile variables to correct order of them, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 05287d9 11/36: Merge pull request #12 from sergeyklay/feature/buttercup,
Stefan Monnier <=
- [elpa] externals/bnf-mode 99a45b6 12/36: Code cleanup, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 164101e 13/36: Merge pull request #13 from sergeyklay/feature/buttercup, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode e744d8a 15/36: HTTPS everywhere, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 9d89e81 07/36: Rephrase docs, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 7e6c3c0 08/36: Amended development dependencies, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 8e69700 18/36: Merge pull request #14 from sergeyklay/minor-fixes, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 0bbd059 19/36: Added abbreviation table used in bnf-mode buffers, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode dd6fae4 23/36: Added mised define-abbrev-table call, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 3d5c4fd 30/36: Cleaned up comments syntax propertize for ALGOL 60 style, Stefan Monnier, 2021/03/17
- [elpa] externals/bnf-mode 5b223e8 34/36: Provide canonical BNF sytax, Stefan Monnier, 2021/03/17