Improve diagnostics and Guile corpus handling

This commit is contained in:
2026-04-04 15:54:51 +02:00
parent 6dc717186e
commit bd89fb476e
10 changed files with 556 additions and 90 deletions

38
test/test-cli.scm Normal file
View File

@@ -0,0 +1,38 @@
;;; Tests for (gulie cli)
(use-modules (srfi srfi-64)
(ice-9 textual-ports)
(gulie cli)
(gulie rules surface)
(gulie rules comments))
(test-begin "cli")
(test-group "output-json"
(let ((tmp (string-append (tmpnam) ".scm"))
(cfg (string-append (tmpnam) ".sexp")))
(call-with-output-file tmp
(lambda (p) (display "(define x 42) \n" p)))
(call-with-output-file cfg
(lambda (p) (display "()\n" p)))
(let* ((code #f)
(output (call-with-output-string
(lambda (port)
(parameterize ((current-output-port port))
(set! code
(main (list "gulie"
"--pass" "surface"
"--config" cfg
"--output" "json"
tmp))))))))
(test-equal "exit code reports findings" 1 code)
(test-assert "json array output"
(string-prefix? "[" output))
(test-assert "contains json rule"
(string-contains output "\"rule\":\"trailing-whitespace\""))
(test-assert "does not use standard formatter"
(not (string-contains output ": warning: trailing-whitespace:"))))
(delete-file tmp)
(delete-file cfg)))
(test-end "cli")