;;; 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")