Skip to content

Commit 01939e1

Browse files
committed
Test lint command
1 parent 4c4641b commit 01939e1

File tree

10 files changed

+315
-0
lines changed

10 files changed

+315
-0
lines changed

test/exit-status/lint/Eask

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
(package "lint"
2+
"0.0.1"
3+
"Test project for lint")
4+
(package-file "lint-pkg.el")
5+
6+
(source 'gnu)
7+
(source 'melpa)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
;;; ert-test.el --- Test the command ert -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2022-2024 the Eask authors.
4+
5+
;; This program is free software; you can redistribute it and/or modify
6+
;; it under the terms of the GNU General Public License as published by
7+
;; the Free Software Foundation, either version 3 of the License, or
8+
;; (at your option) any later version.
9+
10+
;; This program is distributed in the hope that it will be useful,
11+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
;; GNU General Public License for more details.
14+
15+
;; You should have received a copy of the GNU General Public License
16+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
;;; Commentary:
19+
20+
;; Tests for the command ert
21+
22+
;;; Code:
23+
24+
(defun my-foo (arg)
25+
".make a lot of checkdoc errors
26+
27+
in this " ignore)
28+
29+
;;; declare-ok.el ends here
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
;;; declare-fail.el --- Test lint declare -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2022-2024 the Eask authors.
4+
5+
;; This program is free software; you can redistribute it and/or modify
6+
;; it under the terms of the GNU General Public License as published by
7+
;; the Free Software Foundation, either version 3 of the License, or
8+
;; (at your option) any later version.
9+
10+
;; This program is distributed in the hope that it will be useful,
11+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
;; GNU General Public License for more details.
14+
15+
;; You should have received a copy of the GNU General Public License
16+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
;;; Commentary:
19+
20+
;;; Code:
21+
22+
(declare-function not-a-function "subr.el" (x y z))
23+
24+
;;; declare-fail.el ends here
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
;;; ert-test.el --- Test the command ert -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2022-2024 the Eask authors.
4+
5+
;; This program is free software; you can redistribute it and/or modify
6+
;; it under the terms of the GNU General Public License as published by
7+
;; the Free Software Foundation, either version 3 of the License, or
8+
;; (at your option) any later version.
9+
10+
;; This program is distributed in the hope that it will be useful,
11+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
;; GNU General Public License for more details.
14+
15+
;; You should have received a copy of the GNU General Public License
16+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
;;; Commentary:
19+
20+
;; Tests for the command ert
21+
22+
;;; Code:
23+
24+
(declare-function ignore "subr.el" (&rest args))
25+
26+
;;; declare-ok.el ends here
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
;;; elisp-lint-ok.el --- Test the linting -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2022-2024 the Eask authors.
4+
5+
;;; Version: 0.0.1
6+
;;; URL: https://foo.com
7+
;;; Package-Requires: ((emacs "28.1"))
8+
9+
;;; Commentary:
10+
11+
;; Tests linting with elisp-lint
12+
;; Also clean for packge lint
13+
14+
;;; Code:
15+
16+
(defun elisp-lint-ok-foo ()
17+
"Nothing here."
18+
(message "ok"))
19+
20+
(provide 'elisp-lint-ok)
21+
;;; elisp-lint-ok.el ends here

test/exit-status/lint/elsa-warn.el

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
;;; elsa-warn.el --- Test elsa linting -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2022-2024 the Eask authors.
4+
5+
;; This program is free software; you can redistribute it and/or modify
6+
;; it under the terms of the GNU General Public License as published by
7+
;; the Free Software Foundation, either version 3 of the License, or
8+
;; (at your option) any later version.
9+
10+
;; This program is distributed in the hope that it will be useful,
11+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
;; GNU General Public License for more details.
14+
15+
;; You should have received a copy of the GNU General Public License
16+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
;;; Commentary:
19+
20+
;; Test elsa.
21+
;; Should only cause warnings
22+
23+
;;; Code:
24+
25+
(defun elsa-warn-foo ()
26+
(some-foo) ;; not declared warning
27+
(message "Ok"))
28+
29+
;;; elsa-warn.el ends here
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
;;; indent-warn.el --- Test indent linting -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2022-2024 the Eask authors.
4+
5+
;; This program is free software; you can redistribute it and/or modify
6+
;; it under the terms of the GNU General Public License as published by
7+
;; the Free Software Foundation, either version 3 of the License, or
8+
;; (at your option) any later version.
9+
10+
;; This program is distributed in the hope that it will be useful,
11+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
;; GNU General Public License for more details.
14+
15+
;; You should have received a copy of the GNU General Public License
16+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
;;; Commentary:
19+
20+
;; Test indent.
21+
;; Should only cause warnings
22+
23+
;;; Code:
24+
25+
(defun indent-warn-foo ()
26+
(if 't
27+
(message "Ok")
28+
(message
29+
"no")))
30+
31+
;;; indent-warn.el ends here

test/exit-status/lint/lint-pkg.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(define-package "lint" "0.0.1" "Test project for lint" 'nil)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
;;; regexp-warn.el --- Test regexp linting -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2022-2024 the Eask authors.
4+
5+
;; This program is free software; you can redistribute it and/or modify
6+
;; it under the terms of the GNU General Public License as published by
7+
;; the Free Software Foundation, either version 3 of the License, or
8+
;; (at your option) any later version.
9+
10+
;; This program is distributed in the hope that it will be useful,
11+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
;; GNU General Public License for more details.
14+
15+
;; You should have received a copy of the GNU General Public License
16+
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
;;; Commentary:
19+
20+
;; Test regexp.
21+
;; Should only cause warnings
22+
23+
;;; Code:
24+
25+
(defun regexp-warn-foo ()
26+
(re-search-backward "^[.:wrod:]$"))
27+
28+
;;; regexp-warn.el ends here

test/exit-status/lint/run.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (C) 2022-2024 the Eask authors.
4+
5+
# This program is free software; you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation; either version 3, or (at your option)
8+
# any later version.
9+
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
15+
# You should have received a copy of the GNU General Public License
16+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
18+
## Commentary:
19+
#
20+
# Test command `lint`
21+
#
22+
23+
set -e
24+
25+
source ./test/fixtures/home/scripts/testing.sh
26+
cd $(dirname "$0")
27+
28+
# partial input
29+
should_error eask lint
30+
31+
echo "checkdoc"
32+
echo "----------"
33+
should_run eask lint checkdoc declare-ok.el
34+
# FIXME
35+
# should_error eask lint checkdoc --strict checkdoc-fail.el
36+
# should_error eask lint checkdoc --strict --allow-error checkdoc-fail.el declare-ok.el
37+
38+
echo "declare"
39+
echo "----------"
40+
should_run eask lint declare declare-ok.el
41+
42+
# warnings are default ignored
43+
should_run eask lint declare declare-fail.el
44+
45+
# --strict
46+
# FIXME should exit with error
47+
# should_error eask lint declare --strict declare-fail.el
48+
49+
# FIXME should exit with error
50+
# should_error eask lint declare --strict --allow-error ./*.el
51+
52+
echo "elint"
53+
echo "----------"
54+
55+
should_run eask lint elint declare-ok.el
56+
# FIXME
57+
# should_error eask lint elint --strict checkdoc-fail.el
58+
59+
echo "elisp-lint"
60+
echo "----------"
61+
62+
# no warnings
63+
should_run eask lint elisp-lint --strict elisp-lint-ok.el
64+
# warnings
65+
should_run eask lint elisp-lint declare-ok.el
66+
67+
should_error eask lint elisp-lint --strict declare-ok.el
68+
OUTPUT="$(should_error eask lint elisp-lint --strict --allow-error checkdoc-fail.el elisp-lint-ok.el )"
69+
echo "$OUTPUT"
70+
should_match "2 files linted" "$OUTPUT"
71+
72+
echo "elsa"
73+
echo "----------"
74+
75+
# no warnings
76+
should_run eask lint elsa elisp-lint-ok.el
77+
# warnings
78+
should_run eask lint elsa elsa-warn.el
79+
# elsa reports some issues as errors here
80+
should_error eask lint elsa declare-ok.el
81+
82+
# FIXME
83+
# should_error eask lint elsa --strict elsa-warn.el
84+
85+
echo "indent"
86+
echo "----------"
87+
88+
should_run eask lint indent indent-warn.el
89+
should_error eask lint indent --strict indent-warn.el
90+
OUTPUT="$(should_error eask lint indent --strict --allow-error indent-warn.el declare-ok.el)"
91+
echo "$OUTPUT"
92+
should_match "2 files linted" "$OUTPUT"
93+
94+
echo "keywords"
95+
echo "----------"
96+
97+
# TODO seems like keywords in actual file are ignored
98+
# only those in Eask file are checked
99+
# but those interfere with --strict handling in other commands
100+
# should_run eask lint keywords
101+
# should_error eask lint keywords --strict
102+
103+
echo "package"
104+
echo "----------"
105+
106+
should_run eask lint package declare-ok.el
107+
# FIXME
108+
# should_error eask lint package --strict declare-ok.el
109+
110+
# note that all files are checked anyway so --allow-error has no effect
111+
112+
echo "regexps"
113+
echo "----------"
114+
115+
should_error eask lint regexps regexp-warn.el
116+
# FIXME regexp throws and is not caught so second file not linted
117+
# OUTPUT="$(should_error eask lint regexps --allow-error regexp-warn.el declare-ok.el)"
118+
# echo "$OUTPUT"
119+
# should_match "2 files linted" "$OUTPUT"

0 commit comments

Comments
 (0)