From 958f30c1635ffc7cd47b929b382a791a9d0db37b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20R=C3=B6hrich?= Date: Mon, 5 Jul 2021 14:54:03 +0200 Subject: hadolint: multiple fixes and adapt expected format (#3678) - Show hadolint rule number in vim gutter in addition to `ALEDetails` - Capture and show error in case of syntax errors - Add tests for error capture - Adapt existing tests fixes: #2333 fixes: #958 --- test/handler/test_hadolint.vader | 59 ++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'test/handler/test_hadolint.vader') diff --git a/test/handler/test_hadolint.vader b/test/handler/test_hadolint.vader index eec71fbc..a88454fa 100644 --- a/test/handler/test_hadolint.vader +++ b/test/handler/test_hadolint.vader @@ -16,34 +16,41 @@ Execute(The hadolint handler should handle a normal example): \ 'lnum': 1, \ 'col': 0, \ 'type': 'W', - \ 'text': "Always tag the version of an image explicitly", + \ 'text': "DL3006: Always tag the version of an image explicitly", \ 'detail': "DL3006 ( https://github.com/hadolint/hadolint/wiki/DL3006 )\n\nAlways tag the version of an image explicitly", \ }, -# \ { -# \ 'lnum': 2, -# \ 'col': 0, -# \ 'type': 'E', -# \ 'text': "MAINTAINER is deprecated", -# \ 'detail': "DL4000 ( https://github.com/hadolint/hadolint/wiki/DL4000 )\n\nMAINTAINER is deprecated", -# \ }, -# \ { -# \ 'lnum': 4, -# \ 'col': 0, -# \ 'type': 'W', -# \ 'text': "Specify version with `yum install -y -`.", -# \ 'detail': "DL3033 ( https://github.com/hadolint/hadolint/wiki/DL3033 )\n\nSpecify version with `yum install -y -`.", -# \ }, -# \ { -# \ 'lnum': 12, -# \ 'col': 0, -# \ 'type': 'W', -# \ 'text': "In POSIX sh, brace expansion is undefined.", -# \ 'detail': "SC2039 ( https://github.com/koalaman/shellcheck/wiki/SC2039 )\n\nIn POSIX sh, brace expansion is undefined.", -# \ }, + \ { + \ 'lnum': 4, + \ 'col': 0, + \ 'type': 'W', + \ 'text': "DL3033: Specify version with `yum install -y -`.", + \ 'detail': "DL3033 ( https://github.com/hadolint/hadolint/wiki/DL3033 )\n\nSpecify version with `yum install -y -`.", + \ }, + \ { + \ 'lnum': 12, + \ 'col': 0, + \ 'type': 'W', + \ 'text': "SC2039: In POSIX sh, brace expansion is undefined.", + \ 'detail': "SC2039 ( https://github.com/koalaman/shellcheck/wiki/SC2039 )\n\nIn POSIX sh, brace expansion is undefined.", + \ }, + \ ], + \ ale_linters#dockerfile#hadolint#Handle(bufnr(''), [ + \ '-:1 DL3006 warning: Always tag the version of an image explicitly', + \ '-:4 DL3033 warning: Specify version with `yum install -y -`.', + \ '-:12 SC2039 warning: In POSIX sh, brace expansion is undefined.', + \ ]) + +Execute(The hadolint handler should handle parsing errors): + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 1, + \ 'type': 'E', + \ 'text': "unexpected 'b' expecting '#', ADD, ARG, CMD, COPY, ENTRYPOINT, ENV, EXPOSE, FROM, HEALTHCHECK, LABEL, MAINTAINER, ONBUILD, RUN, SHELL, STOPSIGNAL, USER, VOLUME, WORKDIR, or end of input", + \ 'detail': "hadolint could not parse the file because of a syntax error.", + \ }, \ ], \ ale_linters#dockerfile#hadolint#Handle(bufnr(''), [ - \ '/dev/stdin:1 DL3006 warning: Always tag the version of an image explicitly', -# \ '/dev/stdin:2 DL4000 error: MAINTAINER is deprecated', -# \ '/dev/stdin:4 DL3033 warning: Specify version with `yum install -y -`.', -# \ '/dev/stdin:12 SC2039 warning: In POSIX sh, brace expansion is undefined.' + \ '/dev/stdin:1:1 unexpected ''b'' expecting ''#'', ADD, ARG, CMD, COPY, ENTRYPOINT, ENV, EXPOSE, FROM, HEALTHCHECK, LABEL, MAINTAINER, ONBUILD, RUN, SHELL, STOPSIGNAL, USER, VOLUME, WORKDIR, or end of input', \ ]) -- cgit v1.2.3