summaryrefslogtreecommitdiff
path: root/test/command_callback
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-05-08 22:59:25 +0100
committerw0rp <devw0rp@gmail.com>2017-05-08 22:59:25 +0100
commit6ea00af6895e111320a2047f43f94792a46b6cea (patch)
tree8a941fa08834e5dd512f3136b3c9b836ebf1b3d4 /test/command_callback
parent28c6ec9cad3064966ff70c9da95c96364118eb57 (diff)
downloadale-6ea00af6895e111320a2047f43f94792a46b6cea.zip
#540 Fix shell escaping pretty much everywhere
Diffstat (limited to 'test/command_callback')
-rw-r--r--test/command_callback/test_cppcheck_command_callbacks.vader4
-rw-r--r--test/command_callback/test_flake8_command_callback.vader26
-rw-r--r--test/command_callback/test_javac_command_callback.vader16
-rw-r--r--test/command_callback/test_luacheck_command_callback.vader6
-rw-r--r--test/command_callback/test_mypy_command_callback.vader14
-rw-r--r--test/command_callback/test_pylint_command_callback.vader12
6 files changed, 39 insertions, 39 deletions
diff --git a/test/command_callback/test_cppcheck_command_callbacks.vader b/test/command_callback/test_cppcheck_command_callbacks.vader
index 665b4f13..63958643 100644
--- a/test/command_callback/test_cppcheck_command_callbacks.vader
+++ b/test/command_callback/test_cppcheck_command_callbacks.vader
@@ -19,7 +19,7 @@ Execute(cppcheck for C should detect compile_commands.json files):
cd cppcheck_paths/one
AssertEqual
- \ 'cd ' . fnameescape(b:dir . '/cppcheck_paths/one') . ' && '
+ \ 'cd ' . shellescape(b:dir . '/cppcheck_paths/one') . ' && '
\ . 'cppcheck -q --language=c --project=compile_commands.json --enable=style %t',
\ ale_linters#c#cppcheck#GetCommand(bufnr(''))
@@ -35,6 +35,6 @@ Execute(cppcheck for C++ should detect compile_commands.json files):
cd cppcheck_paths/one
AssertEqual
- \ 'cd ' . fnameescape(b:dir . '/cppcheck_paths/one') . ' && '
+ \ 'cd ' . shellescape(b:dir . '/cppcheck_paths/one') . ' && '
\ . 'cppcheck -q --language=c++ --project=compile_commands.json --enable=style %t',
\ ale_linters#cpp#cppcheck#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_flake8_command_callback.vader b/test/command_callback/test_flake8_command_callback.vader
index baec5335..7c1f8c78 100644
--- a/test/command_callback/test_flake8_command_callback.vader
+++ b/test/command_callback/test_flake8_command_callback.vader
@@ -22,26 +22,26 @@ Execute(The flake8 callbacks should return the correct default values):
\ 'flake8',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ 'flake8 --version',
+ \ '''flake8'' --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ 'flake8 --stdin-display-name %s -',
+ \ '''flake8'' --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
" Try with older versions.
call ale_linters#python#flake8#ClearVersionCache()
AssertEqual
- \ 'flake8 -',
+ \ '''flake8'' -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
Execute(The flake8 command callback should let you set options):
let g:ale_python_flake8_options = '--some-option'
AssertEqual
- \ 'flake8 --some-option --stdin-display-name %s -',
+ \ '''flake8'' --some-option --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.4'])
call ale_linters#python#flake8#ClearVersionCache()
AssertEqual
- \ 'flake8 --some-option -',
+ \ '''flake8'' --some-option -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
Execute(You should be able to set a custom executable and it should be escaped):
@@ -51,10 +51,10 @@ Execute(You should be able to set a custom executable and it should be escaped):
\ 'executable with spaces',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ 'executable\ with\ spaces --version',
+ \ '''executable with spaces'' --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ 'executable\ with\ spaces --stdin-display-name %s -',
+ \ '''executable with spaces'' --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
Execute(The flake8 callbacks should detect virtualenv directories):
@@ -64,10 +64,10 @@ Execute(The flake8 callbacks should detect virtualenv directories):
\ g:dir . '/python_paths/with_virtualenv/env/bin/flake8',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ g:dir . '/python_paths/with_virtualenv/env/bin/flake8 --version',
+ \ '''' . g:dir . '/python_paths/with_virtualenv/env/bin/flake8'' --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ g:dir . '/python_paths/with_virtualenv/env/bin/flake8'
+ \ '''' . g:dir . '/python_paths/with_virtualenv/env/bin/flake8'''
\ . ' --stdin-display-name %s -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
@@ -82,10 +82,10 @@ Execute(Using `python -m flake8` should be supported for running flake8):
\ 'python',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ 'python -m flake8 --version',
+ \ '''python'' -m flake8 --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ 'python -m flake8 --some-option -',
+ \ '''python'' -m flake8 --some-option -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
call ale_linters#python#flake8#ClearVersionCache()
@@ -97,8 +97,8 @@ Execute(Using `python -m flake8` should be supported for running flake8):
\ 'python',
\ ale_linters#python#flake8#GetExecutable(bufnr(''))
AssertEqual
- \ 'python -m flake8 --version',
+ \ '''python'' -m flake8 --version',
\ ale_linters#python#flake8#VersionCheck(bufnr(''))
AssertEqual
- \ 'python -m flake8 --some-option -',
+ \ '''python'' -m flake8 --some-option -',
\ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
diff --git a/test/command_callback/test_javac_command_callback.vader b/test/command_callback/test_javac_command_callback.vader
index 534e63de..2f0bc50e 100644
--- a/test/command_callback/test_javac_command_callback.vader
+++ b/test/command_callback/test_javac_command_callback.vader
@@ -15,7 +15,7 @@ After:
Execute(The javac callback should return the correct default value):
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
- Assert match(b:command, '\v^javac +-Xlint +-d +/tmp/[0-9a-zA-Z/]+ +\%t$') >= 0,
+ Assert match(b:command, '\v^javac +-Xlint +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
\ 'Invalid command string: ' . b:command
Execute(The javac callback should use g:ale_java_javac_classpath correctly):
@@ -23,7 +23,7 @@ Execute(The javac callback should use g:ale_java_javac_classpath correctly):
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
- Assert match(b:command, '\v^javac +-Xlint +-cp +foo\.jar +-d +/tmp/[0-9a-zA-Z/]+ +\%t$') >= 0,
+ Assert match(b:command, '\v^javac +-Xlint +-cp ''+foo\.jar'' +-d ''+/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
\ 'Invalid command string: ' . b:command
Execute(The javac callback should include discovered classpaths):
@@ -34,7 +34,7 @@ Execute(The javac callback should include discovered classpaths):
\ '/xyz/abc.jar',
\])
- Assert match(b:command, '\v^javac +-Xlint +-cp +/foo/bar\.jar:/xyz/abc\.jar +-d +/tmp/[0-9a-zA-Z/]+ +\%t$') >= 0,
+ Assert match(b:command, '\v^javac +-Xlint +-cp ''+/foo/bar\.jar:/xyz/abc\.jar'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
\ 'Invalid command string: ' . b:command
Execute(The javac callback should combine discovered classpaths and manual ones):
@@ -47,7 +47,7 @@ Execute(The javac callback should combine discovered classpaths and manual ones)
\ '/xyz/abc.jar',
\])
- Assert match(b:command, '\v^javac +-Xlint +-cp +/foo/bar\.jar:/xyz/abc\.jar:configured\.jar +-d +/tmp/[0-9a-zA-Z/]+ +\%t$') >= 0,
+ Assert match(b:command, '\v^javac +-Xlint +-cp +''/foo/bar\.jar:/xyz/abc\.jar:configured\.jar'' +-d ''+/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
\ 'Invalid command string: ' . b:command
let g:ale_java_javac_classpath = 'configured.jar:configured2.jar'
@@ -59,7 +59,7 @@ Execute(The javac callback should combine discovered classpaths and manual ones)
\ '/xyz/abc.jar',
\])
- Assert match(b:command, '\v^javac +-Xlint +-cp +/foo/bar\.jar:/xyz/abc\.jar:configured\.jar:configured2\.jar +-d +/tmp/[0-9a-zA-Z/]+ +\%t$') >= 0,
+ Assert match(b:command, '\v^javac +-Xlint +-cp +''/foo/bar\.jar:/xyz/abc\.jar:configured\.jar:configured2\.jar'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
\ 'Invalid command string: ' . b:command
Execute(The javac callback should detect source directories):
@@ -69,7 +69,7 @@ Execute(The javac callback should detect source directories):
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
- Assert match(b:command, '\v^javac +-Xlint +-sourcepath /.*java_paths/src/main/java/ +-d +/tmp/[0-9a-zA-Z/]+ +\%t$') >= 0,
+ Assert match(b:command, '\v^javac +-Xlint +-sourcepath ''/.*java_paths/src/main/java/'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
\ 'Invalid command string: ' . b:command
Execute(The javac callback should combine detected source directories and classpaths):
@@ -84,7 +84,7 @@ Execute(The javac callback should combine detected source directories and classp
\ '/xyz/abc.jar',
\])
- Assert match(b:command, '\v^javac +-Xlint +-cp +/foo/bar\.jar:/xyz/abc\.jar +-sourcepath /.*java_paths/src/main/java/ +-d +/tmp/[0-9a-zA-Z/]+ +\%t$') >= 0,
+ Assert match(b:command, '\v^javac +-Xlint +-cp +''/foo/bar\.jar:/xyz/abc\.jar'' +-sourcepath ''/.*java_paths/src/main/java/'' +-d +''/tmp/[0-9a-zA-Z/]+'' +\%t$') >= 0,
\ 'Invalid command string: ' . b:command
Execute(The javac callback should use g:ale_java_javac_options correctly):
@@ -93,5 +93,5 @@ Execute(The javac callback should use g:ale_java_javac_options correctly):
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
- Assert match(b:command, '\v^javac +-Xlint +-d +/tmp/[0-9a-zA-Z/]+ --anything --else +\%t$') >= 0,
+ Assert match(b:command, '\v^javac +-Xlint +-d +''/tmp/[0-9a-zA-Z/]+'' --anything --else +\%t$') >= 0,
\ 'Invalid command string: ' . b:command
diff --git a/test/command_callback/test_luacheck_command_callback.vader b/test/command_callback/test_luacheck_command_callback.vader
index f283b987..c4ee98a8 100644
--- a/test/command_callback/test_luacheck_command_callback.vader
+++ b/test/command_callback/test_luacheck_command_callback.vader
@@ -7,18 +7,18 @@ After:
let g:ale_lua_luacheck_executable = 'luacheck'
Execute(The lua luacheck command callback should return the correct default string):
- AssertEqual 'luacheck --formatter plain --codes --filename %s -',
+ AssertEqual '''luacheck'' --formatter plain --codes --filename %s -',
\ join(split(ale_linters#lua#luacheck#GetCommand(1)))
Execute(The lua luacheck command callback should let you set options):
let g:ale_lua_luacheck_options = '--config filename'
- AssertEqual 'luacheck --config filename --formatter plain --codes --filename %s -',
+ AssertEqual '''luacheck'' --config filename --formatter plain --codes --filename %s -',
\ join(split(ale_linters#lua#luacheck#GetCommand(1)))
Execute(The luacheck executable should be configurable):
let g:ale_lua_luacheck_executable = 'luacheck.sh'
AssertEqual 'luacheck.sh', ale_linters#lua#luacheck#GetExecutable(1)
- AssertEqual 'luacheck.sh --formatter plain --codes --filename %s -',
+ AssertEqual '''luacheck.sh'' --formatter plain --codes --filename %s -',
\ join(split(ale_linters#lua#luacheck#GetCommand(1)))
diff --git a/test/command_callback/test_mypy_command_callback.vader b/test/command_callback/test_mypy_command_callback.vader
index ec82c879..14c9af43 100644
--- a/test/command_callback/test_mypy_command_callback.vader
+++ b/test/command_callback/test_mypy_command_callback.vader
@@ -20,7 +20,7 @@ Execute(The mypy callbacks should return the correct default values):
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ' . g:dir . ' && mypy --show-column-numbers %s',
+ \ 'cd ''' . g:dir . ''' && ''mypy'' --show-column-numbers %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy executable should be configurable, and escaped properly):
@@ -30,14 +30,14 @@ Execute(The mypy executable should be configurable, and escaped properly):
\ 'executable with spaces',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ' . g:dir . ' && executable\ with\ spaces --show-column-numbers %s',
+ \ 'cd ''' . g:dir . ''' && ''executable with spaces'' --show-column-numbers %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy command callback should let you set options):
let g:ale_python_mypy_options = '--some-option'
AssertEqual
- \ 'cd ' . g:dir . ' && mypy --show-column-numbers --some-option %s',
+ \ 'cd ''' . g:dir . ''' && ''mypy'' --show-column-numbers --some-option %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy command should switch directories to the detected project root):
@@ -47,7 +47,7 @@ Execute(The mypy command should switch directories to the detected project root)
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ' . g:dir . '/python_paths/no_virtualenv/subdir && mypy --show-column-numbers %s',
+ \ 'cd ''' . g:dir . '/python_paths/no_virtualenv/subdir'' && ''mypy'' --show-column-numbers %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(The mypy callbacks should detect virtualenv directories and switch to the project root):
@@ -57,8 +57,8 @@ Execute(The mypy callbacks should detect virtualenv directories and switch to th
\ g:dir . '/python_paths/with_virtualenv/env/bin/mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ' . g:dir . '/python_paths/with_virtualenv/subdir && '
- \ . g:dir . '/python_paths/with_virtualenv/env/bin/mypy --show-column-numbers %s',
+ \ 'cd ''' . g:dir . '/python_paths/with_virtualenv/subdir'' && '''
+ \ . g:dir . '/python_paths/with_virtualenv/env/bin/mypy'' --show-column-numbers %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
Execute(You should able able to use the global mypy instead):
@@ -69,5 +69,5 @@ Execute(You should able able to use the global mypy instead):
\ 'mypy',
\ ale_linters#python#mypy#GetExecutable(bufnr(''))
AssertEqual
- \ 'cd ' . g:dir . '/python_paths/with_virtualenv/subdir && mypy --show-column-numbers %s',
+ \ 'cd ''' . g:dir . '/python_paths/with_virtualenv/subdir'' && ''mypy'' --show-column-numbers %s',
\ ale_linters#python#mypy#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_pylint_command_callback.vader b/test/command_callback/test_pylint_command_callback.vader
index 533d06a2..040c9ef0 100644
--- a/test/command_callback/test_pylint_command_callback.vader
+++ b/test/command_callback/test_pylint_command_callback.vader
@@ -21,7 +21,7 @@ Execute(The pylint callbacks should return the correct default values):
\ 'pylint',
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
AssertEqual
- \ 'pylint ' . b:command_tail,
+ \ '''pylint'' ' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
Execute(The pylint executable should be configurable, and escaped properly):
@@ -31,14 +31,14 @@ Execute(The pylint executable should be configurable, and escaped properly):
\ 'executable with spaces',
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
AssertEqual
- \ 'executable\ with\ spaces ' . b:command_tail,
+ \ '''executable with spaces'' ' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
Execute(The pylint command callback should let you set options):
let g:ale_python_pylint_options = '--some-option'
AssertEqual
- \ 'pylint --some-option' . b:command_tail,
+ \ '''pylint'' --some-option' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
Execute(The pylint callbacks shouldn't detect virtualenv directories where they don't exist):
@@ -48,7 +48,7 @@ Execute(The pylint callbacks shouldn't detect virtualenv directories where they
\ 'pylint',
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
AssertEqual
- \ 'pylint ' . b:command_tail,
+ \ '''pylint'' ' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
Execute(The pylint callbacks should detect virtualenv directories):
@@ -58,7 +58,7 @@ Execute(The pylint callbacks should detect virtualenv directories):
\ g:dir . '/python_paths/with_virtualenv/env/bin/pylint',
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
AssertEqual
- \ g:dir . '/python_paths/with_virtualenv/env/bin/pylint ' . b:command_tail,
+ \ ''''. g:dir . '/python_paths/with_virtualenv/env/bin/pylint'' ' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))
Execute(You should able able to use the global pylint instead):
@@ -69,5 +69,5 @@ Execute(You should able able to use the global pylint instead):
\ 'pylint',
\ ale_linters#python#pylint#GetExecutable(bufnr(''))
AssertEqual
- \ 'pylint ' . b:command_tail,
+ \ '''pylint'' ' . b:command_tail,
\ ale_linters#python#pylint#GetCommand(bufnr(''))