Repository navigation
Expand file tree
/
Copy pathEldev
More file actions
160 lines (140 loc) · 7.83 KB
/
Copy pathEldev
File metadata and controls
160 lines (140 loc) · 7.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
; -*- mode: emacs-lisp; lexical-binding: t -*-
(eldev-require-version "1.11.2")
(setf eldev-project-source-dirs '("lisp/"))
(setf eldev-project-main-file "cider.el")
(eldev-use-package-archive 'gnu)
;; For compatibility; e.g. with MELPA Stable one test fails.
(eldev-use-package-archive 'melpa-unstable)
(eldev-use-plugin 'autoloads)
(eldev-add-loading-roots 'test "test/utils")
(eldev-add-extra-dependencies 'runtime '(:package logview :optional t))
(eldev-add-extra-dependencies 'runtime '(:package clojure-ts-mode :optional t))
;; slightly increase the maximum (applies to checkdoc and the byte compiler alike)
(setq byte-compile-docstring-max-column 100)
;; allow commas to indicate that the first sentence continues, which enables longer first sentences
(setq checkdoc-permit-comma-termination-flag t)
;; the experimental third-person-verb check misfires on nouns like "tests"
;; and "highlights", which a Clojure IDE can hardly avoid in docstrings
(setq checkdoc-verb-check-experimental-flag nil)
(defvar cider-test-type 'main)
(setf eldev-standard-excludes `(:or ,eldev-standard-excludes
;; Exclude flycheck temporary files
"./flycheck_*.el"
;; Avoid including files in test "projects".
(eldev-pcase-exhaustive cider-test-type
(`main "./test/*/")
(`integration '("./test/" "!./test/integration"))
(`clojure-ts-mode '("./test/*/" "!./test/clojure-ts-mode"))
(`all '("./test/*/" "!./test/integration")))
"test/integration/projects"
;; This file is _supposed_ to be excluded
;; from automated testing.
"test/cider-tests--no-auto.el"))
(eldev-defoption cider-test-selection (type)
"Select tests to run; type can be `main', `integration', `clojure-ts-mode' or `all'"
:options (-T --test-type)
:for-command test
:value TYPE
:default-value cider-test-type
(unless (memq (intern type) '(main integration clojure-ts-mode all))
(signal 'eldev-wrong-option-usage `("unknown test type `%s'" ,type)))
(setf cider-test-type (intern type)))
;; The main suite sets up its buffers with `clojure-mode'. This option
;; reroutes every such call to `clojure-ts-mode', so the whole suite (not
;; just the handful of specs under test/clojure-ts-mode/) exercises the
;; tree-sitter code paths.
(defvar cider-test-under-clojure-ts-mode nil)
(eldev-defoption cider-test-under-clojure-ts-mode ()
"Run the specs with `clojure-mode' buffers switched to `clojure-ts-mode'"
:options (--under-clojure-ts-mode)
:for-command test
(setf cider-test-under-clojure-ts-mode t))
(add-hook 'eldev-load-dependencies-hook
(lambda (type additional-sets)
(when (and (or (eq cider-test-type 'clojure-ts-mode)
cider-test-under-clojure-ts-mode)
(member 'runtime additional-sets))
(message "Installing tree-sitter grammars")
;; An already-installed optional dependency isn't activated
;; this early in the run (a fresh install is), so activate it
;; explicitly before requiring it.
(package-activate 'clojure-ts-mode)
(require 'clojure-ts-mode)
(clojure-ts--ensure-grammars)
(when cider-test-under-clojure-ts-mode
(message "Routing `clojure-mode' to `clojure-ts-mode' for this run")
(advice-add 'clojure-mode :override
(lambda (&rest _) (clojure-ts-mode)))))))
(add-hook 'eldev-test-hook
(lambda ()
(eldev-verbose "Using cider tests of type `%s'" cider-test-type)))
(add-hook 'eldev-executing-command-hook
(lambda (command)
(unless (eq command 'test)
;; So that e.g. byte-compilation works on all tests.
(setf cider-test-type 'all))))
;; CIDER cannot be compiled otherwise.
(setf eldev-build-load-before-byte-compiling t)
;; Emacs 31 stamps source positions onto compiler-macro expansions in place
;; (`macroexp--posify-form'), which corrupts the stored inline body of any
;; argument-less `cl-defsubst' - `queue-create' is the one that bites us -
;; once something calling it has been byte-compiled in this process. In
;; packaged mode Eldev compiles CIDER right before loading the specs, so the
;; first test run after a source change failed 9 specs with
;; `invalid-function cl-block' (Emacs bug#79599). Upstream added this switch
;; for exactly that kind of trouble; the only cost is less precise positions
;; in byte-compile warnings.
(setq macroexp-enable-preserve-posification nil)
;; On macOS bsdtar stores extended attributes as `._*' AppleDouble entries,
;; and Eldev's packaged copy of the project would then get a hundred of them
;; byte-compiled as Lisp.
(setenv "COPYFILE_DISABLE" "1")
;; package-lint is disabled because nrepl-*.el files intentionally use
;; the `nrepl-' prefix instead of the `cider-' package prefix.
;; `doc' is the linter's canonical name; `checkdoc' is only a command-line
;; alias, and the default-linter matching doesn't resolve aliases - with
;; `(checkdoc)' here, a bare `eldev lint' (which is what CI runs) silently
;; lints nothing.
(setf eldev-lint-default '(doc))
;; Coverage reports via undercover. Off unless asked for, so this changes
;; nothing for regular runs and CI; the flags given to `-u' take precedence.
;; Use `eldev test -u on,text' for a summary or
;; `eldev test -u on,simplecov -U coverage.json' for a per-line report.
;; Don't combine with `-p': the instrumentation needs the sources as-is.
(eldev-use-plugin 'undercover)
(setf eldev-undercover-config '(off))
;; Native compilation byte-compiles every file in a fresh Emacs that only
;; knows what the file itself requires or declares. `eldev compile' builds
;; everything in one process, where functions defined by earlier files hide
;; a missing `require' or `declare-function', so native-comp users saw
;; warnings that CI never did. This compiles each file on its own instead.
(eldev-defcommand cider-compile-isolated (&rest _)
"Byte-compile each source file in a separate Emacs and fail on warnings."
:command compile-isolated
(eldev-load-project-dependencies 'runtime nil t)
(let ((out-dir (make-temp-file "cider-isolated" t))
(failed nil))
(unwind-protect
(dolist (file (directory-files (expand-file-name "lisp") t "\\`[^.].*\\.el\\'"))
(eldev-call-process eldev-emacs-executable
(list "-Q" "-batch" "-eval"
(prin1-to-string
`(progn
(require 'bytecomp)
(setq load-path ',load-path
load-prefer-newer t
byte-compile-docstring-max-column ,byte-compile-docstring-max-column
byte-compile-dest-file-function
(lambda (_) ,(expand-file-name
(concat (file-name-base file) ".elc")
out-dir)))
(byte-compile-file ,file))))
:trace-command-line t
(goto-char (point-min))
(when (or (/= exit-code 0)
(re-search-forward "\\(Warning\\|Error\\):" nil t))
(setq failed t)
(eldev-warn "%s" (buffer-string)))))
(delete-directory out-dir t))
(when failed
(signal 'eldev-error '("Some files don't compile cleanly on their own")))))