Skip to content

Commit

Permalink
Add systemd unit config checker
Browse files Browse the repository at this point in the history
  • Loading branch information
holomorph committed Oct 18, 2016
1 parent e86fa19 commit 8cff7d7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
@@ -1,6 +1,10 @@
31-cvs (in development)
=======================

- New syntax checkers:

- systemd-analyze with ``systemd-analyze`` [GH-1135]

30 (Oct 12, 2016)
=================

Expand Down
7 changes: 7 additions & 0 deletions doc/languages.rst
Expand Up @@ -1075,6 +1075,13 @@ to view the docstring of the syntax checker. Likewise, you may use

Check SQL syntax with `Sqlint <https://github.com/purcell/sqlint>`_.

.. supported-language:: systemd Unit Configuration

.. syntax-checker:: systemd-analyze

Check systemd unit configuration file syntax with
`systemd-analyze <https://www.freedesktop.org/software/systemd/man/systemd-analyze.html>`_.

.. supported-language:: TeX/LaTeX

Flycheck checks TeX and LaTeX with either `tex-chktex` or `tex-lacheck`.
Expand Down
10 changes: 10 additions & 0 deletions flycheck.el
Expand Up @@ -246,6 +246,7 @@ attention to case differences."
slim
slim-lint
sql-sqlint
systemd-analyze
tex-chktex
tex-lacheck
texinfo
Expand Down Expand Up @@ -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)

Expand Down
10 changes: 10 additions & 0 deletions test/flycheck-test.el
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions 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]

0 comments on commit 8cff7d7

Please sign in to comment.