summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristian-Gibbons <cgibbons@gmu.edu>2018-03-10 05:44:55 -0500
committerw0rp <w0rp@users.noreply.github.com>2018-03-10 10:44:55 +0000
commitb586eba4a498af3ab156f59376344958d8d20db1 (patch)
treefed48f079d0d496ad93dc04890f495b2a7ef1f8a /test
parent0a0535546f4d9a0dfe02671630fdaba72ea5828d (diff)
downloadale-b586eba4a498af3ab156f59376344958d8d20db1.zip
Handle flawfinder severity level (#1400)
* Handle flawfinder severity level * Reverted code allowing Flawfinder to piggyback off of gcc's format handler * Gave Flawfinder its own format handler and made requested changes.
Diffstat (limited to 'test')
-rw-r--r--test/handler/test_flawfinder_handler.vader57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/handler/test_flawfinder_handler.vader b/test/handler/test_flawfinder_handler.vader
new file mode 100644
index 00000000..708bac2a
--- /dev/null
+++ b/test/handler/test_flawfinder_handler.vader
@@ -0,0 +1,57 @@
+Before:
+ Save g:ale_c_flawfinder_error_severity
+
+ unlet! g:ale_c_flawfinder_error_severity
+ unlet! b:ale_c_flawfinder_error_severity
+
+ runtime ale_linters/c/flawfinder.vim
+
+After:
+ unlet! g:ale_c_flawfinder_error_severity
+ Restore
+
+Execute(The Flawfinder handler should ignore other lines of output):
+ AssertEqual
+ \ [],
+ \ ale#handlers#flawfinder#HandleFlawfinderFormat(347, [
+ \ 'foo',
+ \ 'bar',
+ \ 'baz',
+ \ ])
+
+Execute(The Flawfinder handler should work):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 31,
+ \ 'col': 4,
+ \ 'type': 'W',
+ \ 'text': "(buffer) strncpy: Easily used incorrectly",
+ \ },
+ \ ],
+ \ ale#handlers#flawfinder#HandleFlawfinderFormat(347, [
+ \ "<stdin>:31:4: [1] (buffer) strncpy:Easily used incorrectly",
+ \ ])
+
+Execute(The Flawfinder error severity level should be configurable):
+ let b:ale_c_flawfinder_error_severity = 2
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 12,
+ \ 'col': 4,
+ \ 'type': 'E',
+ \ 'text': "(buffer) char: Statically-sized arrays can be bad",
+ \ },
+ \ {
+ \ 'lnum': 31,
+ \ 'col': 4,
+ \ 'type': 'W',
+ \ 'text': "(buffer) strncpy: Easily used incorrectly",
+ \ },
+ \ ],
+ \ ale#handlers#flawfinder#HandleFlawfinderFormat(bufnr(''), [
+ \ "<stdin>:12:4: [2] (buffer) char:Statically-sized arrays can be bad",
+ \ "<stdin>:31:4: [1] (buffer) strncpy:Easily used incorrectly",
+ \ ])