From 85d86620f7459fd7caf14e4b8be2880006b36881 Mon Sep 17 00:00:00 2001 From: w0rp Date: Mon, 3 Apr 2017 22:24:30 +0100 Subject: Cover basic GCC functionality with tests --- test/c_tests/test_gcc.vader | 63 +++++++++++++++++++++++++++++++++++++++++++++ test/vimrc | 1 + 2 files changed, 64 insertions(+) create mode 100644 test/c_tests/test_gcc.vader (limited to 'test') diff --git a/test/c_tests/test_gcc.vader b/test/c_tests/test_gcc.vader new file mode 100644 index 00000000..67e4e426 --- /dev/null +++ b/test/c_tests/test_gcc.vader @@ -0,0 +1,63 @@ +Before: + Save g:ale_run_synchronously + Save g:ale_linters + Save g:ale_history_log_output + Save g:ale_cpp_gcc_options + + silent! cd /testplugin/test/c_tests + + let g:ale_run_synchronously = 1 + let g:ale_linters = {'c': ['gcc'], 'cpp': ['g++']} + let g:ale_history_log_output = 1 + let g:ale_cpp_gcc_options = '-Wall' + + function! GetCommandOutput() + if empty(g:ale_buffer_info[bufnr('')].history) + return '' + endif + + return join(g:ale_buffer_info[bufnr('')].history[-1].output, "\n") + endfunction + +After: + Restore + delfunction GetCommandOutput + call ale#linter#Reset() + call ale#engine#SetResults(bufnr(''), []) + call ale#cleanup#Buffer(bufnr('')) + +Given c (A test C file): + int main() { + return 0 + } + +Execute(Basic errors should be returned for GCC for C files): + call ale#Lint() + + AssertEqual [{ + \ 'lnum': 3, + \ 'col': 1, + \ }], + \ map(getloclist(0), '{''lnum'': v:val.lnum, ''col'': v:val.col}'), + \ 'No errors returned! Got: ' . GetCommandOutput() + + Assert match(getloclist(0)[0].text, '\v^expected .*;.* before .*\}.* token$') >= 0, + \ 'Invalid error text: ' . getloclist(0)[0].text + +Given cpp (A test C++ file): + int main() { + return 0 + } + +Execute(Basic errors should be returned for GCC for C++ files): + call ale#Lint() + + AssertEqual [{ + \ 'lnum': 3, + \ 'col': 1, + \ }], + \ map(getloclist(0), '{''lnum'': v:val.lnum, ''col'': v:val.col}'), + \ 'No errors returned! Got: ' . GetCommandOutput() + + Assert match(getloclist(0)[0].text, '\v^expected .*;.* before .*\}.* token$') >= 0, + \ 'Invalid error text: ' . getloclist(0)[0].text diff --git a/test/vimrc b/test/vimrc index 197be979..57af7e15 100644 --- a/test/vimrc +++ b/test/vimrc @@ -8,6 +8,7 @@ set runtimepath=/home/vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,/testplu filetype plugin indent on syntax on set shell=/bin/sh +set shellcmdflag=-c set nocompatible set tabstop=4 set softtabstop=4 -- cgit v1.2.3