diff options
author | w0rp <devw0rp@gmail.com> | 2019-04-15 21:38:11 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2019-04-15 21:38:11 +0100 |
commit | 23a8208498047c98108ca74f63ace023ecb1c232 (patch) | |
tree | 9a904654673e399117a7bb4053622829c591404e /test/test_c_flag_parsing.vader | |
parent | 7f31065fce89cca492c21c8bd73c74aa9f9432b2 (diff) | |
download | ale-23a8208498047c98108ca74f63ace023ecb1c232.zip |
#782 - Use compile commands for matching source files for headers
Diffstat (limited to 'test/test_c_flag_parsing.vader')
-rw-r--r-- | test/test_c_flag_parsing.vader | 98 |
1 files changed, 93 insertions, 5 deletions
diff --git a/test/test_c_flag_parsing.vader b/test/test_c_flag_parsing.vader index 340f3ccf..045554a3 100644 --- a/test/test_c_flag_parsing.vader +++ b/test/test_c_flag_parsing.vader @@ -153,10 +153,10 @@ Execute(ParseCompileCommandsFlags should tolerate empty values): AssertEqual '', ale#c#ParseCompileCommandsFlags(bufnr(''), {}, {}) Execute(ParseCompileCommandsFlags should parse some basic flags): - noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c')) + silent noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c')) AssertEqual - \ '-I' . '/usr/include/xmms2', + \ '-I/usr/include/xmms2', \ ale#c#ParseCompileCommandsFlags(bufnr(''), { "xmms2-mpris.c": [ \ { \ 'directory': '/foo/bar/xmms2-mpris', @@ -168,7 +168,7 @@ Execute(ParseCompileCommandsFlags should parse some basic flags): \ ] }, {}) Execute(ParseCompileCommandsFlags should tolerate items without commands): - noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c')) + silent noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c')) AssertEqual \ '', @@ -180,10 +180,10 @@ Execute(ParseCompileCommandsFlags should tolerate items without commands): \ ] }, {}) Execute(ParseCompileCommandsFlags should fall back to files in the same directory): - noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c')) + silent noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c')) AssertEqual - \ '-I' . '/usr/include/xmms2', + \ '-I/usr/include/xmms2', \ ale#c#ParseCompileCommandsFlags(bufnr(''), {}, { "src": [ \ { \ 'directory': '/foo/bar/xmms2-mpris', @@ -194,6 +194,94 @@ Execute(ParseCompileCommandsFlags should fall back to files in the same director \ }, \ ] }) +Execute(ParseCompileCommandsFlags should take commands from matching .c files for .h files): + silent noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.h')) + + AssertEqual + \ '-I/usr/include/xmms2', + \ ale#c#ParseCompileCommandsFlags( + \ bufnr(''), + \ { + \ 'xmms2-mpris.c': [ + \ { + \ 'directory': '/foo/bar/xmms2-mpris', + \ 'file': (has('win32') ? 'C:' : '') . '/foo/bar/xmms2-mpris/src/xmms2-mpris.c', + \ 'command': '/usr/bin/cc -I' . '/usr/include/xmms2' + \ . ' -o CMakeFiles/xmms2-mpris.dir/src/xmms2-mpris.c.o' + \ . ' -c ' . '/foo/bar/xmms2-mpris/src/xmms2-mpris.c', + \ }, + \ ], + \ }, + \ { + \ }, + \ ) + +Execute(ParseCompileCommandsFlags should take commands from matching .cpp files for .hpp files): + silent noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.hpp')) + + AssertEqual + \ '-I/usr/include/xmms2', + \ ale#c#ParseCompileCommandsFlags( + \ bufnr(''), + \ { + \ 'xmms2-mpris.cpp': [ + \ { + \ 'directory': '/foo/bar/xmms2-mpris', + \ 'file': (has('win32') ? 'C:' : '') . '/foo/bar/xmms2-mpris/src/xmms2-mpris.cpp', + \ 'command': '/usr/bin/cc -I' . '/usr/include/xmms2' + \ . ' -o CMakeFiles/xmms2-mpris.dir/src/xmms2-mpris.c.o' + \ . ' -c ' . '/foo/bar/xmms2-mpris/src/xmms2-mpris.cpp', + \ }, + \ ], + \ }, + \ { + \ }, + \ ) + +Execute(ParseCompileCommandsFlags should take commands from matching .cpp files for .h files): + silent noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.h')) + + AssertEqual + \ '-I/usr/include/xmms2', + \ ale#c#ParseCompileCommandsFlags( + \ bufnr(''), + \ { + \ 'xmms2-mpris.cpp': [ + \ { + \ 'directory': '/foo/bar/xmms2-mpris', + \ 'file': (has('win32') ? 'C:' : '') . '/foo/bar/xmms2-mpris/src/xmms2-mpris.cpp', + \ 'command': '/usr/bin/cc -I' . '/usr/include/xmms2' + \ . ' -o CMakeFiles/xmms2-mpris.dir/src/xmms2-mpris.c.o' + \ . ' -c ' . '/foo/bar/xmms2-mpris/src/xmms2-mpris.cpp', + \ }, + \ ], + \ }, + \ { + \ }, + \ ) + +Execute(ParseCompileCommandsFlags should not take commands from .c files for .h files with different names): + silent noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/other.h')) + + AssertEqual + \ '', + \ ale#c#ParseCompileCommandsFlags( + \ bufnr(''), + \ { + \ 'xmms2-mpris.c': [ + \ { + \ 'directory': '/foo/bar/xmms2-mpris', + \ 'file': (has('win32') ? 'C:' : '') . '/foo/bar/xmms2-mpris/src/xmms2-mpris.c', + \ 'command': '/usr/bin/cc -I' . '/usr/include/xmms2' + \ . ' -o CMakeFiles/xmms2-mpris.dir/src/xmms2-mpris.c.o' + \ . ' -c ' . '/foo/bar/xmms2-mpris/src/xmms2-mpris.c', + \ }, + \ ], + \ }, + \ { + \ }, + \ ) + Execute(ParseCFlags should handle parenthesis and quotes): AssertEqual \ '-Dgoal=9 -Dtest1="('' '')" file1.o -Dtest2=''(` `)'' file2.o -Dtest3=`(" ")` file3.o', |