From ff288366165804e8956013cca8c1291536cf9707 Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Fri, 8 Sep 2017 19:06:47 +0900 Subject: Add GLSL linter using glslang (#914) * Add a glslang linter for GLSL --- .../test_glslang_command_callback.vader | 42 ++++++++++++++++++++++ test/handler/test_glslang_handler.vader | 21 +++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/command_callback/test_glslang_command_callback.vader create mode 100644 test/handler/test_glslang_handler.vader (limited to 'test') diff --git a/test/command_callback/test_glslang_command_callback.vader b/test/command_callback/test_glslang_command_callback.vader new file mode 100644 index 00000000..9d406834 --- /dev/null +++ b/test/command_callback/test_glslang_command_callback.vader @@ -0,0 +1,42 @@ +Before: + Save g:ale_glsl_glslang_executable + Save g:ale_glsl_glslang_options + + unlet! g:ale_glsl_glslang_executable + unlet! g:ale_glsl_glslang_options + + runtime ale_linters/glsl/glslang.vim + call ale#test#SetDirectory('/testplugin/test/command_callback') + +After: + Restore + unlet! g:ale_cuda_nvcc_executable + unlet! g:ale_cuda_nvcc_options + call ale#linter#Reset() + +Execute(Executable should default to glslangValidator): + AssertEqual + \ 'glslangValidator', + \ ale_linters#glsl#glslang#GetExecutable(bufnr('')) + +Execute(Executable should be configurable): + let g:ale_glsl_glslang_executable = 'foobar' + AssertEqual + \ 'foobar', + \ ale_linters#glsl#glslang#GetExecutable(bufnr('')) + +Execute(Command should use executable): + AssertEqual + \ 'glslangValidator -C %t', + \ ale_linters#glsl#glslang#GetCommand(bufnr('')) + + let g:ale_glsl_glslang_executable = 'foobar' + AssertEqual + \ 'foobar -C %t', + \ ale_linters#glsl#glslang#GetCommand(bufnr('')) + +Execute(Options should work): + let g:ale_glsl_glslang_options = '--test' + AssertEqual + \ 'glslangValidator --test -C %t', + \ ale_linters#glsl#glslang#GetCommand(bufnr('')) diff --git a/test/handler/test_glslang_handler.vader b/test/handler/test_glslang_handler.vader new file mode 100644 index 00000000..d51c9852 --- /dev/null +++ b/test/handler/test_glslang_handler.vader @@ -0,0 +1,21 @@ +Execute(The glsl glslang handler should parse lines correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 4, + \ 'col': 0, + \ 'type': 'E', + \ 'text': '''gl_ModelViewProjectionMatrix'' : undeclared identifier', + \ }, + \ { + \ 'lnum': 121, + \ 'col': 0, + \ 'type': 'W', + \ 'text': '''switch'' : last case/default label not followed by statements', + \ }, + \ ], + \ ale_linters#glsl#glslang#Handle(bufnr(''), [ + \ 'ERROR: 0:4: ''gl_ModelViewProjectionMatrix'' : undeclared identifier', + \ 'WARNING: 0:121: ''switch'' : last case/default label not followed by statements', + \ 'ERROR: 2 compilation errors. No code generated.', + \ ]) -- cgit v1.2.3