branch: elpa/flycheck
commit 02b3c394b7c95faa0dbea897d5133c87695a7695
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Add tests for checkers with missing coverage
Add Buttercup specs for python-ruff, markdownlint-cli2,
css-stylelint, scss-stylelint, javascript-oxlint, and
yaml-actionlint. These checkers previously had no test coverage.
---
.../language/.github/workflows/test-action.yml | 6 ++++++
test/resources/language/css/.stylelintrc.json | 5 +++++
test/specs/languages/test-actionlint.el | 13 +++++++++++++
test/specs/languages/test-css.el | 16 ++++++++++++++++
test/specs/languages/test-javascript.el | 8 ++++++++
test/specs/languages/test-markdown.el | 12 ++++++++++++
test/specs/languages/test-python.el | 21 +++++++++++++++++++++
test/specs/languages/test-scss.el | 16 ++++++++++++++++
8 files changed, 97 insertions(+)
diff --git a/test/resources/language/.github/workflows/test-action.yml
b/test/resources/language/.github/workflows/test-action.yml
new file mode 100644
index 0000000000..c02bfc8eaf
--- /dev/null
+++ b/test/resources/language/.github/workflows/test-action.yml
@@ -0,0 +1,6 @@
+on: push
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - run: echo ${{ inputs.foo }}
diff --git a/test/resources/language/css/.stylelintrc.json
b/test/resources/language/css/.stylelintrc.json
new file mode 100644
index 0000000000..1ddddccec3
--- /dev/null
+++ b/test/resources/language/css/.stylelintrc.json
@@ -0,0 +1,5 @@
+{
+ "rules": {
+ "no-empty-source": true
+ }
+}
diff --git a/test/specs/languages/test-actionlint.el
b/test/specs/languages/test-actionlint.el
new file mode 100644
index 0000000000..042b021ae2
--- /dev/null
+++ b/test/specs/languages/test-actionlint.el
@@ -0,0 +1,13 @@
+;;; test-actionlint.el --- Flycheck Specs: Actionlint -*- lexical-binding: t;
-*-
+;;; Code:
+(require 'flycheck-buttercup)
+(require 'test-helpers)
+
+(describe "Language YAML (actionlint)"
+ (flycheck-buttercup-def-checker-test yaml-actionlint yaml nil
+ (flycheck-buttercup-should-syntax-check
+ "language/.github/workflows/test-action.yml" 'yaml-mode
+ '(6 23 error "property \"foo\" is not defined in object type {}
[expression]"
+ :checker yaml-actionlint))))
+
+;;; test-actionlint.el ends here
diff --git a/test/specs/languages/test-css.el b/test/specs/languages/test-css.el
new file mode 100644
index 0000000000..ca2b26351c
--- /dev/null
+++ b/test/specs/languages/test-css.el
@@ -0,0 +1,16 @@
+;;; test-css.el --- Flycheck Specs: CSS -*- lexical-binding: t; -*-
+;;; Code:
+(require 'flycheck-buttercup)
+(require 'test-helpers)
+
+(describe "Language CSS"
+ (flycheck-buttercup-def-checker-test css-stylelint css syntax-error
+ (let ((flycheck-stylelintrc
+ (flycheck-buttercup-resource-filename
+ "language/css/.stylelintrc.json")))
+ (flycheck-buttercup-should-syntax-check
+ "language/css/syntax-error.css" 'css-mode
+ '(4 5 error "Unknown word font-size (CssSyntaxError)"
+ :id "CssSyntaxError" :checker css-stylelint)))))
+
+;;; test-css.el ends here
diff --git a/test/specs/languages/test-javascript.el
b/test/specs/languages/test-javascript.el
index 530cc99c21..72d5c27e7f 100644
--- a/test/specs/languages/test-javascript.el
+++ b/test/specs/languages/test-javascript.el
@@ -91,6 +91,14 @@
:id "no-unused-vars" :checker javascript-eslint
:end-line 4 :end-column 12))))
+ (flycheck-buttercup-def-checker-test javascript-oxlint javascript nil
+ (let ((flycheck-checker 'javascript-oxlint)
+ (inhibit-message t))
+ (flycheck-buttercup-should-syntax-check
+ "language/javascript/warnings.js" flycheck-test-javascript-modes
+ '(4 9 warning "Variable 'foo' is declared but never used. Unused
variables should start with a '_'."
+ :id "eslint(no-unused-vars)" :checker javascript-oxlint))))
+
(flycheck-buttercup-def-checker-test javascript-standard javascript error
(let ((flycheck-checker 'javascript-standard)
(inhibit-message t))
diff --git a/test/specs/languages/test-markdown.el
b/test/specs/languages/test-markdown.el
index 7a25f77819..cf6c7bb57c 100644
--- a/test/specs/languages/test-markdown.el
+++ b/test/specs/languages/test-markdown.el
@@ -14,6 +14,18 @@
'(4 15 error "Trailing spaces [Expected: 0 or 2; Actual: 7]"
:id "MD009/no-trailing-spaces" :checker markdown-markdownlint-cli)))
+ (flycheck-buttercup-def-checker-test markdown-markdownlint-cli2 markdown nil
+ (let ((flycheck-disabled-checkers '(markdown-markdownlint-cli))
+ (flycheck-markdown-markdownlint-cli2-config nil))
+ (flycheck-buttercup-should-syntax-check
+ "language/markdown.md" 'markdown-mode
+ '(1 nil error "First line in a file should be a top-level heading
[Context: \"## Second Header First\"]"
+ :id "MD041/first-line-heading/first-line-h1" :checker
markdown-markdownlint-cli2)
+ '(3 nil error "Multiple consecutive blank lines [Expected: 1; Actual:
2]"
+ :id "MD012/no-multiple-blanks" :checker markdown-markdownlint-cli2)
+ '(4 15 error "Trailing spaces [Expected: 0 or 2; Actual: 7]"
+ :id "MD009/no-trailing-spaces" :checker
markdown-markdownlint-cli2))))
+
(flycheck-buttercup-def-checker-test markdown-mdl markdown nil
(let ((flycheck-disabled-checkers '(markdown-markdownlint-cli
markdown-markdownlint-cli2 markdown-pymarkdown)))
(flycheck-buttercup-should-syntax-check
diff --git a/test/specs/languages/test-python.el
b/test/specs/languages/test-python.el
index f320ab556b..b45344f6b6 100644
--- a/test/specs/languages/test-python.el
+++ b/test/specs/languages/test-python.el
@@ -46,6 +46,27 @@
'(2 12 error "Incompatible return value type (got \"str\", expected
\"int\")"
:id "return-value" :checker python-mypy))))
+ (flycheck-buttercup-def-checker-test python-ruff python syntax-error
+ (let ((flycheck-disabled-checkers '(python-flake8))
+ (flycheck-checkers '(python-ruff))
+ (python-indent-guess-indent-offset nil))
+ (flycheck-buttercup-should-syntax-check
+ "language/python/syntax-error.py" 'python-mode
+ '(3 7 error "Expected an identifier, but found a keyword `import` that
cannot be used here"
+ :checker python-ruff)
+ '(3 14 error "Simple statements must be separated by newlines or
semicolons"
+ :checker python-ruff))))
+
+ (flycheck-buttercup-def-checker-test python-ruff python nil
+ (let ((flycheck-disabled-checkers '(python-flake8))
+ (flycheck-checkers '(python-ruff)))
+ (flycheck-buttercup-should-syntax-check
+ "language/python/test.py" 'python-mode
+ '(5 15 warning "[*] `.antigravit` imported but unused" :id "F401"
+ :checker python-ruff)
+ '(22 1 error "Undefined name `antigravity`" :id "F821"
+ :checker python-ruff))))
+
(flycheck-buttercup-def-checker-test python-pylint python nil
(let ((flycheck-disabled-checkers '(python-flake8 python-mypy))
(flycheck-python-pylint-executable "python3"))
diff --git a/test/specs/languages/test-scss.el
b/test/specs/languages/test-scss.el
new file mode 100644
index 0000000000..7b8f22aad1
--- /dev/null
+++ b/test/specs/languages/test-scss.el
@@ -0,0 +1,16 @@
+;;; test-scss.el --- Flycheck Specs: SCSS -*- lexical-binding: t; -*-
+;;; Code:
+(require 'flycheck-buttercup)
+(require 'test-helpers)
+
+(describe "Language SCSS"
+ (flycheck-buttercup-def-checker-test scss-stylelint scss syntax-error
+ (let ((flycheck-stylelintrc
+ (flycheck-buttercup-resource-filename
+ "language/css/.stylelintrc.json")))
+ (flycheck-buttercup-should-syntax-check
+ "language/scss/error.scss" 'scss-mode
+ '(3 11 error "Unknown word olor (CssSyntaxError)"
+ :id "CssSyntaxError" :checker scss-stylelint)))))
+
+;;; test-scss.el ends here