Format '--check' errors so that tooling can detect them
This commit is contained in:
parent
e6e209d4a2
commit
d4343392ab
@ -20,7 +20,7 @@
|
||||
(let [file (files.get-by-uri server (.. "file://" filename))]
|
||||
(lint.check server file)
|
||||
(each [_ {: message :range {: start}} (ipairs file.diagnostics)]
|
||||
(print (: "%s:%s:%s %s" :format filename
|
||||
(print (: "%s:%s:%s: %s" :format filename
|
||||
;; LSP line numbers are zero-indexed, but Emacs and Vim both use
|
||||
;; 1-indexing for this.
|
||||
(+ (or start.line 0) 1) (or start.character "?") message)))
|
||||
|
||||
18
test/check.fnl
Normal file
18
test/check.fnl
Normal file
@ -0,0 +1,18 @@
|
||||
(local faith (require :faith))
|
||||
|
||||
;; TODO refactor fennel-ls.check to avoid running end-to-end
|
||||
;; (but keep/write at least some end-to-end tests)
|
||||
(fn test-check []
|
||||
(let [input-file-name (os.tmpname)]
|
||||
(doto (io.open input-file-name :w)
|
||||
(: :write "(local x 1)")
|
||||
(: :close))
|
||||
(let [output-file (io.popen (.. "./fennel-ls --check "
|
||||
input-file-name)
|
||||
:r)]
|
||||
(faith.= (.. input-file-name ":1:7: unused definition: x\n")
|
||||
(output-file:read :*a) )
|
||||
(os.remove input-file-name))
|
||||
nil))
|
||||
|
||||
{: test-check}
|
||||
@ -24,4 +24,5 @@
|
||||
:test.lint
|
||||
:test.code-action
|
||||
:test.rename
|
||||
:test.misc])
|
||||
:test.misc
|
||||
:test.check])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user