summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2018-07-29 19:24:19 +0100
committerw0rp <devw0rp@gmail.com>2018-07-29 19:24:27 +0100
commitac4bac8ea4c5a8d520041ad509e10af454fcfce4 (patch)
tree87a57a03149b62116b8e1b6fa96117e5e3186626 /test
parenta7b8cb4fe32b43dbeeadc8cb94f378b4e2112723 (diff)
downloadale-ac4bac8ea4c5a8d520041ad509e10af454fcfce4.zip
Add support for parsing compile_commands.json files for C compilers
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_c_clang_command_callbacks.vader3
-rw-r--r--test/command_callback/test_c_gcc_command_callbacks.vader3
-rw-r--r--test/command_callback/test_cpp_clang_command_callbacks.vader3
-rw-r--r--test/command_callback/test_cpp_gcc_command_callbacks.vader3
-rw-r--r--test/test_c_flag_parsing.vader161
-rw-r--r--test/test_c_import_paths.vader2
-rw-r--r--test/test_c_parse_makefile.vader184
-rw-r--r--test/test_path_dirname.vader8
8 files changed, 183 insertions, 184 deletions
diff --git a/test/command_callback/test_c_clang_command_callbacks.vader b/test/command_callback/test_c_clang_command_callbacks.vader
index 87f7fd06..7d2ff0bf 100644
--- a/test/command_callback/test_c_clang_command_callbacks.vader
+++ b/test/command_callback/test_c_clang_command_callbacks.vader
@@ -1,4 +1,7 @@
Before:
+ Save g:ale_c_parse_makefile
+ let g:ale_c_parse_makefile = 0
+
call ale#assert#SetUpLinterTest('c', 'clang')
let b:command_tail = ' -S -x c -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd())
diff --git a/test/command_callback/test_c_gcc_command_callbacks.vader b/test/command_callback/test_c_gcc_command_callbacks.vader
index 45514051..1f51c3bc 100644
--- a/test/command_callback/test_c_gcc_command_callbacks.vader
+++ b/test/command_callback/test_c_gcc_command_callbacks.vader
@@ -1,4 +1,7 @@
Before:
+ Save g:ale_c_parse_makefile
+ let g:ale_c_parse_makefile = 0
+
call ale#assert#SetUpLinterTest('c', 'gcc')
let b:command_tail = ' -S -x c -fsyntax-only -iquote'
diff --git a/test/command_callback/test_cpp_clang_command_callbacks.vader b/test/command_callback/test_cpp_clang_command_callbacks.vader
index 3a5ea945..e96fd8e7 100644
--- a/test/command_callback/test_cpp_clang_command_callbacks.vader
+++ b/test/command_callback/test_cpp_clang_command_callbacks.vader
@@ -1,4 +1,7 @@
Before:
+ Save g:ale_c_parse_makefile
+ let g:ale_c_parse_makefile = 0
+
call ale#assert#SetUpLinterTest('cpp', 'clang')
let b:command_tail = ' -S -x c++ -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd())
diff --git a/test/command_callback/test_cpp_gcc_command_callbacks.vader b/test/command_callback/test_cpp_gcc_command_callbacks.vader
index f9fad8c8..0a86df4f 100644
--- a/test/command_callback/test_cpp_gcc_command_callbacks.vader
+++ b/test/command_callback/test_cpp_gcc_command_callbacks.vader
@@ -1,4 +1,7 @@
Before:
+ Save g:ale_c_parse_makefile
+ let g:ale_c_parse_makefile = 0
+
call ale#assert#SetUpLinterTest('cpp', 'gcc')
let b:command_tail = ' -S -x c++ -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd())
diff --git a/test/test_c_flag_parsing.vader b/test/test_c_flag_parsing.vader
new file mode 100644
index 00000000..8bd805df
--- /dev/null
+++ b/test/test_c_flag_parsing.vader
@@ -0,0 +1,161 @@
+Before:
+ Save g:ale_c_parse_makefile
+
+ call ale#test#SetDirectory('/testplugin/test')
+
+ let g:ale_c_parse_makefile = 1
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The CFlags parser should be able to parse include directives):
+ call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
+
+ AssertEqual
+ \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
+ \ ale#c#ParseCFlagsFromMakeOutput(bufnr(''), ['gcc -Isubdir -c file.c'])
+
+Execute(The CFlags parser should be able to parse macro directives):
+ call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
+
+ AssertEqual
+ \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
+ \ . ' -DTEST=1',
+ \ ale#c#ParseCFlagsFromMakeOutput(bufnr(''), ['gcc -Isubdir -DTEST=1 -c file.c'])
+
+Execute(The CFlags parser should be able to parse macro directives with spaces):
+ call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
+
+ AssertEqual
+ \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
+ \ . ' -DTEST=$(( 2 * 4 ))',
+ \ ale#c#ParseCFlagsFromMakeOutput(bufnr(''), ['gcc -Isubdir -DTEST=$(( 2 * 4 )) -c file.c'])
+
+Execute(The CFlags parser should be able to parse shell directives with spaces):
+ call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
+
+ AssertEqual
+ \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
+ \ . ' -DTEST=`date +%s`',
+ \ ale#c#ParseCFlagsFromMakeOutput(bufnr(''), ['gcc -Isubdir -DTEST=`date +%s` -c file.c'])
+
+Execute(ParseCFlags should be able to parse flags with relative paths):
+ AssertEqual
+ \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include'))
+ \ . ' -DTEST=`date +%s`',
+ \ ale#c#ParseCFlags(
+ \ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
+ \ 'gcc -Isubdir '
+ \ . '-I'. ale#path#Simplify('kernel/include')
+ \ . ' -DTEST=`date +%s` -c file.c'
+ \ )
+
+Execute(ParseCFlags should be able to parse -Dgoal):
+ AssertEqual
+ \ '-Dgoal=9'
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include'))
+ \ . ' -DTEST=`date +%s`',
+ \ ale#c#ParseCFlags(
+ \ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
+ \ 'gcc -Dgoal=9 -Isubdir '
+ \ . '-I'. ale#path#Simplify('kernel/include')
+ \ . ' -DTEST=`date +%s` -c file.c'
+ \ )
+
+Execute(ParseCFlags should ignore -T and other arguments):
+ AssertEqual
+ \ '-Dgoal=9'
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include'))
+ \ . ' -DTEST=`date +%s`',
+ \ ale#c#ParseCFlags(
+ \ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
+ \ 'gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir '
+ \ . '-I'. ale#path#Simplify('kernel/include')
+ \ . ' -DTEST=`date +%s` -c file.c'
+ \ )
+
+Execute(ParseCFlags should handle paths with spaces in double quotes):
+ AssertEqual
+ \ '-Dgoal=9'
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include'))
+ \ . ' -DTEST=`date +%s`',
+ \ ale#c#ParseCFlags(
+ \ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
+ \ 'gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir '
+ \ . '-I"dir with spaces"' . ' -I'. ale#path#Simplify('kernel/include')
+ \ . ' -DTEST=`date +%s` -c file.c'
+ \ )
+
+Execute(ParseCFlags should handle paths with spaces in single quotes):
+ AssertEqual
+ \ '-Dgoal=9'
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include'))
+ \ . ' -DTEST=`date +%s`',
+ \ ale#c#ParseCFlags(
+ \ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
+ \ 'gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir '
+ \ . '-I''dir with spaces''' . ' -I'. ale#path#Simplify('kernel/include')
+ \ . ' -DTEST=`date +%s` -c file.c'
+ \ )
+
+Execute(ParseCFlags should handle paths with minuses):
+ AssertEqual
+ \ '-Dgoal=9'
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir-with-dash'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include'))
+ \ . ' -DTEST=`date +%s`',
+ \ ale#c#ParseCFlags(
+ \ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
+ \ 'gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir '
+ \ . '-I''dir with spaces''' . ' -Idir-with-dash'
+ \ . ' -I'. ale#path#Simplify('kernel/include')
+ \ . ' -DTEST=`date +%s` -c file.c'
+ \ )
+
+Execute(ParseCFlags should handle -D with minuses):
+ AssertEqual
+ \ '-Dgoal=9'
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))
+ \ . ' -Dmacro-with-dash'
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir-with-dash'))
+ \ . ' ' . ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include'))
+ \ . ' -DTEST=`date +%s`',
+ \ ale#c#ParseCFlags(
+ \ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
+ \ 'gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir '
+ \ . '-Dmacro-with-dash '
+ \ . '-I''dir with spaces''' . ' -Idir-with-dash'
+ \ . ' -I'. ale#path#Simplify('kernel/include')
+ \ . ' -DTEST=`date +%s` -c file.c'
+ \ )
+
+Execute(FlagsFromCompileCommands should tolerate empty values):
+ AssertEqual '', ale#c#FlagsFromCompileCommands(bufnr(''), '')
+
+Execute(ParseCompileCommandsFlags should tolerate empty values):
+ AssertEqual '', ale#c#ParseCompileCommandsFlags(bufnr(''), '', [])
+
+Execute(ParseCompileCommandsFlags should parse some basic flags):
+ noautocmd execute 'file! ' . fnameescape('/foo/bar/xmms2-mpris/src/xmms2-mpris.c')
+
+ AssertEqual
+ \ '-I/usr/include/xmms2',
+ \ ale#c#ParseCompileCommandsFlags(bufnr(''), '/foo/bar/xmms2-mpris', [
+ \ {
+ \ 'directory': '/foo/bar/xmms2-mpris',
+ \ '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',
+ \ 'file': '/foo/bar/xmms2-mpris/src/xmms2-mpris.c'
+ \ },
+ \ ])
diff --git a/test/test_c_import_paths.vader b/test/test_c_import_paths.vader
index 0490dec6..70b25070 100644
--- a/test/test_c_import_paths.vader
+++ b/test/test_c_import_paths.vader
@@ -2,6 +2,7 @@ Before:
" Make sure the c.vim file is loaded first.
call ale#c#FindProjectRoot(bufnr(''))
+ Save g:ale_c_parse_makefile
Save g:ale_c_gcc_options
Save g:ale_c_clang_options
Save g:ale_cpp_gcc_options
@@ -19,6 +20,7 @@ Before:
call ale#test#SetDirectory('/testplugin/test')
+ let g:ale_c_parse_makefile = 0
let g:ale_c_gcc_options = ''
let g:ale_c_clang_options = ''
let g:ale_cpp_gcc_options = ''
diff --git a/test/test_c_parse_makefile.vader b/test/test_c_parse_makefile.vader
deleted file mode 100644
index 7c2fc21e..00000000
--- a/test/test_c_parse_makefile.vader
+++ /dev/null
@@ -1,184 +0,0 @@
-Before:
- Save g:ale_c_parse_makefile
- Save g:ale_c_gcc_options
- Save g:ale_c_clang_options
- Save g:ale_cpp_gcc_options
- Save g:ale_cpp_clang_options
-
- call ale#test#SetDirectory('/testplugin/test')
-
- let g:ale_c_parse_makefile=1
- let g:ale_c_gcc_options = ''
- let g:ale_c_clang_options = ''
- let g:ale_cpp_gcc_options = ''
- let g:ale_cpp_clang_options = ''
-
-After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
-
-Execute(The CFlags parser should be able to parse include directives):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir'))]
- \ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -c file.c')
-
-Execute(The CFlags parser should be able to parse macro directives):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ '-DTEST=1']
- \ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -DTEST=1 -c file.c')
-
-Execute(The CFlags parser should be able to parse macro directives with spaces):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ '-DTEST=$(( 2 * 4 ))']
- \ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -DTEST=$(( 2 * 4 )) -c file.c')
-
-Execute(The CFlags parser should be able to parse shell directives with spaces):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ '-DTEST=`date +%s`']
- \ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -DTEST=`date +%s` -c file.c')
-
-Execute(The CFlagsToList parser should be able to parse multiple cflags):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ '-DTEST=`date +%s`']
- \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
- \ split('gcc -Isubdir -DTEST=`date +%s` -c file.c', '-'))
-
-Execute(The CFlagsToList parser should be able to parse multiple cflags #2):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ [ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')),
- \ '-DTEST=`date +%s`']
- \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
- \ split('gcc -Isubdir ' .
- \ '-I'. ale#path#Simplify('kernel/include') .
- \ ' -DTEST=`date +%s` -c file.c', '-'))
-
-Execute(The CFlagsToList parser should be able to parse multiple cflags #3):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ ['-Dgoal=9',
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')),
- \ '-DTEST=`date +%s`']
- \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
- \ split('gcc -Dgoal=9 -Isubdir ' .
- \ '-I'. ale#path#Simplify('kernel/include') .
- \ ' -DTEST=`date +%s` -c file.c', '-'))
-
-Execute(The CFlagsToList parser should be able to parse multiple cflags #4):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ ['-Dgoal=9',
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')),
- \ '-DTEST=`date +%s`']
- \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
- \ split('gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir ' .
- \ '-I'. ale#path#Simplify('kernel/include') .
- \ ' -DTEST=`date +%s` -c file.c', '-'))
-
-Execute(The CFlagsToList parser should be able to parse multiple cflags #5):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ ['-Dgoal=9',
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')),
- \ '-DTEST=`date +%s`']
- \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
- \ split('gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir ' .
- \ '-I"dir with spaces"' . ' -I'. ale#path#Simplify('kernel/include') .
- \ ' -DTEST=`date +%s` -c file.c', '-'))
-
-Execute(The CFlagsToList parser should be able to parse multiple cflags #6):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ ['-Dgoal=9',
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')),
- \ '-DTEST=`date +%s`']
- \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
- \ split('gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir ' .
- \ '-I''dir with spaces''' . ' -I'. ale#path#Simplify('kernel/include') .
- \ ' -DTEST=`date +%s` -c file.c', '-'))
-
-Execute(The CFlagsToList parser should be able to parse multiple cflags #7):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ ['-Dgoal=9',
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir-with-dash')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')),
- \ '-DTEST=`date +%s`']
- \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
- \ split('gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir ' .
- \ '-I''dir with spaces''' . ' -Idir-with-dash' .
- \ ' -I'. ale#path#Simplify('kernel/include') .
- \ ' -DTEST=`date +%s` -c file.c', '-'))
-
-Execute(The CFlagsToList parser should be able to parse multiple cflags #8):
- runtime! ale_linters/c/gcc.vim
-
- call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
-
- AssertEqual
- \ ['-Dgoal=9',
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/subdir')),
- \ '-Dmacro-with-dash',
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir with spaces')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/dir-with-dash')),
- \ ale#Escape('-I' . ale#path#Simplify(g:dir. '/test_c_projects/makefile_project/kernel/include')),
- \ '-DTEST=`date +%s`']
- \ , ale#c#ParseCFlagsToList(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
- \ split('gcc -Dgoal=9 -Tlinkerfile.ld blabla -Isubdir ' .
- \ '-Dmacro-with-dash ' .
- \ '-I''dir with spaces''' . ' -Idir-with-dash' .
- \ ' -I'. ale#path#Simplify('kernel/include') .
- \ ' -DTEST=`date +%s` -c file.c', '-'))
diff --git a/test/test_path_dirname.vader b/test/test_path_dirname.vader
new file mode 100644
index 00000000..79b78d29
--- /dev/null
+++ b/test/test_path_dirname.vader
@@ -0,0 +1,8 @@
+Execute(ale#path#Dirname should return empty strings should be returned for empty values):
+ AssertEqual '', ale#path#Dirname('')
+ AssertEqual '', ale#path#Dirname(0)
+ AssertEqual '', ale#path#Dirname(v:null)
+
+Execute(ale#path#Dirname should return the dirname of paths):
+ AssertEqual '/foo', ale#path#Dirname('/foo/bar')
+ AssertEqual '/foo', ale#path#Dirname('/foo/bar/')