From 8cff7d73223b35803f9effa574006e07a8b11d7b Mon Sep 17 00:00:00 2001 From: Mark Oteiza Date: Sat, 15 Oct 2016 12:35:13 -0400 Subject: [PATCH] Add systemd unit config checker Fixes GH-1135 --- CHANGES.rst | 4 ++++ doc/languages.rst | 7 +++++++ flycheck.el | 10 ++++++++++ test/flycheck-test.el | 10 ++++++++++ test/resources/language/systemd-analyze-test.service | 8 ++++++++ 5 files changed, 39 insertions(+) create mode 100644 test/resources/language/systemd-analyze-test.service diff --git a/CHANGES.rst b/CHANGES.rst index 28e010d44..b83c04bf6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,10 @@ 31-cvs (in development) ======================= +- New syntax checkers: + + - systemd-analyze with ``systemd-analyze`` [GH-1135] + 30 (Oct 12, 2016) ================= diff --git a/doc/languages.rst b/doc/languages.rst index 28c7765c9..6e4ae1e2a 100644 --- a/doc/languages.rst +++ b/doc/languages.rst @@ -1075,6 +1075,13 @@ to view the docstring of the syntax checker. Likewise, you may use Check SQL syntax with `Sqlint `_. +.. supported-language:: systemd Unit Configuration + + .. syntax-checker:: systemd-analyze + + Check systemd unit configuration file syntax with + `systemd-analyze `_. + .. supported-language:: TeX/LaTeX Flycheck checks TeX and LaTeX with either `tex-chktex` or `tex-lacheck`. diff --git a/flycheck.el b/flycheck.el index cb3f20b17..afad869dd 100644 --- a/flycheck.el +++ b/flycheck.el @@ -246,6 +246,7 @@ attention to case differences." slim slim-lint sql-sqlint + systemd-analyze tex-chktex tex-lacheck texinfo @@ -9139,6 +9140,15 @@ See URL `https://github.com/purcell/sqlint'." line-end)) :modes (sql-mode)) +(flycheck-define-checker systemd-analyze + "A systemd unit checker using systemd-analyze(1). + +See URL `https://www.freedesktop.org/software/systemd/man/systemd-analyze.html'." + :command ("systemd-analyze" "verify" source-original) + :error-patterns + ((error line-start "[" (file-name) ":" line "] " (message) line-end)) + :modes (systemd-mode)) + (flycheck-def-config-file-var flycheck-chktexrc tex-chktex ".chktexrc" :safe #'stringp) diff --git a/test/flycheck-test.el b/test/flycheck-test.el index ab023b878..61ae557d3 100644 --- a/test/flycheck-test.el +++ b/test/flycheck-test.el @@ -4010,6 +4010,16 @@ Why not: `(1 15 error "unterminated quoted string at or near \"';\n \" (scan.l:1087)" :checker sql-sqlint))) +(flycheck-ert-def-checker-test systemd-analyze systemd nil + (flycheck-ert-should-syntax-check + "language/systemd-analyze-test.service" 'systemd-mode + '(3 nil error "Invalid URL, ignoring: foo://bar" + :checker systemd-analyze) + '(6 nil error "Unknown lvalue 'ExecSmart' in section 'Service'" + :checker systemd-analyze) + '(8 nil error "Unknown section 'Dog'. Ignoring." + :checker systemd-analyze))) + (flycheck-ert-def-checker-test tex-chktex (tex latex) nil (flycheck-ert-should-syntax-check "language/tex.tex" 'latex-mode diff --git a/test/resources/language/systemd-analyze-test.service b/test/resources/language/systemd-analyze-test.service new file mode 100644 index 000000000..dce23db6d --- /dev/null +++ b/test/resources/language/systemd-analyze-test.service @@ -0,0 +1,8 @@ +[Unit] +Description=Test file for flycheck systemd-analyze checker +Documentation=foo://bar + +[Service] +ExecSmart= + +[Dog]