summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_brakeman_command_callback.vader7
-rw-r--r--test/command_callback/test_flake8_command_callback.vader10
-rw-r--r--test/command_callback/test_gometalinter_command_callback.vader8
-rw-r--r--test/command_callback/test_mypy_command_callback.vader10
-rw-r--r--test/command_callback/test_puglint_command_callback.vader7
-rw-r--r--test/command_callback/test_pylint_command_callback.vader11
-rw-r--r--test/command_callback/test_rubocop_command_callback.vader20
-rw-r--r--test/fixers/test_autopep8_fixer_callback.vader8
-rw-r--r--test/fixers/test_isort_fixer_callback.vader8
-rw-r--r--test/fixers/test_puppetlint_fixer_callback.vader8
-rw-r--r--test/fixers/test_rubocop_fixer_callback.vader8
-rw-r--r--test/fixers/test_yapf_fixer_callback.vader8
-rw-r--r--test/handler/test_cppcheck_handler.vader6
-rw-r--r--test/handler/test_perl_handler.vader7
-rw-r--r--test/handler/test_tslint_handler.vader7
-rw-r--r--test/test_c_import_paths.vader6
-rw-r--r--test/test_csslint_config_detection.vader15
-rw-r--r--test/test_eslint_executable_detection.vader29
-rw-r--r--test/test_foodcritic_command_callback.vader12
-rw-r--r--test/test_phpcs_executable_detection.vader7
20 files changed, 64 insertions, 138 deletions
diff --git a/test/command_callback/test_brakeman_command_callback.vader b/test/command_callback/test_brakeman_command_callback.vader
index 607aec64..b97c5809 100644
--- a/test/command_callback/test_brakeman_command_callback.vader
+++ b/test/command_callback/test_brakeman_command_callback.vader
@@ -5,15 +5,12 @@ Before:
let g:ale_ruby_brakeman_options = ''
- silent! cd /testplugin/test/command_callback
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
After:
Restore
- silent execute 'cd ' . fnameescape(g:dir)
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The brakeman command callback should detect absence of a valid Rails app):
diff --git a/test/command_callback/test_flake8_command_callback.vader b/test/command_callback/test_flake8_command_callback.vader
index 7c1f8c78..42afe65a 100644
--- a/test/command_callback/test_flake8_command_callback.vader
+++ b/test/command_callback/test_flake8_command_callback.vader
@@ -1,15 +1,9 @@
Before:
runtime ale_linters/python/flake8.vim
- silent! execute 'cd /testplugin/test/command_callback'
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
After:
- silent execute 'cd ' . fnameescape(g:dir)
- " Set the file to something else,
- " or we'll cause issues when running other tests
- silent file 'dummy.py'
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
let g:ale_python_flake8_executable = 'flake8'
let g:ale_python_flake8_options = ''
diff --git a/test/command_callback/test_gometalinter_command_callback.vader b/test/command_callback/test_gometalinter_command_callback.vader
index dcaf03b0..24c85aba 100644
--- a/test/command_callback/test_gometalinter_command_callback.vader
+++ b/test/command_callback/test_gometalinter_command_callback.vader
@@ -7,17 +7,13 @@ Before:
runtime ale_linters/go/gometalinter.vim
- silent! cd /testplugin/test/command_callback
- let g:dir = getcwd()
-
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
call ale#test#SetFilename('test.go')
After:
Restore
- silent execute 'cd ' . fnameescape(g:dir)
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The gometalinter callback should return the right defaults):
diff --git a/test/command_callback/test_mypy_command_callback.vader b/test/command_callback/test_mypy_command_callback.vader
index 19141805..8df7193d 100644
--- a/test/command_callback/test_mypy_command_callback.vader
+++ b/test/command_callback/test_mypy_command_callback.vader
@@ -1,15 +1,9 @@
Before:
runtime ale_linters/python/mypy.vim
- silent! execute 'cd /testplugin/test/command_callback'
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
After:
- silent execute 'cd ' . fnameescape(g:dir)
- " Set the file to something else,
- " or we'll cause issues when running other tests
- silent file 'dummy.py'
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
let g:ale_python_mypy_executable = 'mypy'
let g:ale_python_mypy_options = ''
diff --git a/test/command_callback/test_puglint_command_callback.vader b/test/command_callback/test_puglint_command_callback.vader
index 830d63b3..6d189899 100644
--- a/test/command_callback/test_puglint_command_callback.vader
+++ b/test/command_callback/test_puglint_command_callback.vader
@@ -7,17 +7,14 @@ Before:
let g:ale_pug_puglint_executable = 'pug-lint'
let g:ale_pug_puglint_use_global = 0
- silent! cd /testplugin/test/command_callback
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
runtime ale_linters/pug/puglint.vim
After:
Restore
- silent execute 'cd ' . fnameescape(g:dir)
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(puglint should detect local executables and package.json):
diff --git a/test/command_callback/test_pylint_command_callback.vader b/test/command_callback/test_pylint_command_callback.vader
index 040c9ef0..f8f44ab6 100644
--- a/test/command_callback/test_pylint_command_callback.vader
+++ b/test/command_callback/test_pylint_command_callback.vader
@@ -1,16 +1,11 @@
Before:
runtime ale_linters/python/pylint.vim
- silent! execute 'cd /testplugin/test/command_callback'
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+
let b:command_tail = ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'
After:
- silent execute 'cd ' . fnameescape(g:dir)
- " Set the file to something else,
- " or we'll cause issues when running other tests
- silent file 'dummy.py'
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
let g:ale_python_pylint_executable = 'pylint'
let g:ale_python_pylint_options = ''
diff --git a/test/command_callback/test_rubocop_command_callback.vader b/test/command_callback/test_rubocop_command_callback.vader
index db151800..a88d453c 100644
--- a/test/command_callback/test_rubocop_command_callback.vader
+++ b/test/command_callback/test_rubocop_command_callback.vader
@@ -1,19 +1,33 @@
Before:
+ Save g:ale_ruby_rubocop_executable
+
+ let g:ale_ruby_rubocop_executable = 'rubocop'
+
runtime ale_linters/ruby/rubocop.vim
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#test#SetFilename('dummy.rb')
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
Execute(Executable should default to rubocop):
AssertEqual
- \ '''rubocop'' --format json --force-exclusion --stdin ''dummy.py''',
+ \ '''rubocop'' --format json --force-exclusion --stdin '
+ \ . ale#Escape(g:dir . '/dummy.rb'),
\ ale_linters#ruby#rubocop#GetCommand(bufnr(''))
Execute(Should be able to set a custom executable):
let g:ale_ruby_rubocop_executable = 'bin/rubocop'
AssertEqual
- \ '''bin/rubocop'' --format json --force-exclusion --stdin ''dummy.py''',
+ \ '''bin/rubocop'' --format json --force-exclusion --stdin '
+ \ . ale#Escape(g:dir . '/dummy.rb'),
\ ale_linters#ruby#rubocop#GetCommand(bufnr(''))
Execute(Setting bundle appends 'exec rubocop'):
let g:ale_ruby_rubocop_executable = 'path to/bundle'
AssertEqual
- \ '''path to/bundle'' exec rubocop --format json --force-exclusion --stdin ''dummy.py''',
+ \ '''path to/bundle'' exec rubocop --format json --force-exclusion --stdin '
+ \ . ale#Escape(g:dir . '/dummy.rb'),
\ ale_linters#ruby#rubocop#GetCommand(bufnr(''))
diff --git a/test/fixers/test_autopep8_fixer_callback.vader b/test/fixers/test_autopep8_fixer_callback.vader
index 3b5b057c..c8c0bd46 100644
--- a/test/fixers/test_autopep8_fixer_callback.vader
+++ b/test/fixers/test_autopep8_fixer_callback.vader
@@ -6,7 +6,7 @@ Before:
let g:ale_python_autopep8_executable = 'xxxinvalid'
let g:ale_python_autopep8_options = ''
- silent! execute 'cd /testplugin/test/command_callback'
+ call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd ..
silent cd command_callback
let g:dir = getcwd()
@@ -14,11 +14,7 @@ Before:
After:
Restore
- silent execute 'cd ' . fnameescape(g:dir)
- " Set the file to something else,
- " or we'll cause issues when running other tests
- silent file 'dummy.py'
- unlet! g:dir
+ call ale#test#RestoreDirectory()
Execute(The autopep8 callback should return the correct default values):
AssertEqual
diff --git a/test/fixers/test_isort_fixer_callback.vader b/test/fixers/test_isort_fixer_callback.vader
index 495f23c5..437e2764 100644
--- a/test/fixers/test_isort_fixer_callback.vader
+++ b/test/fixers/test_isort_fixer_callback.vader
@@ -4,7 +4,7 @@ Before:
" Use an invalid global executable, so we don't match it.
let g:ale_python_isort_executable = 'xxxinvalid'
- silent! execute 'cd /testplugin/test/command_callback'
+ call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd ..
silent cd command_callback
let g:dir = getcwd()
@@ -12,11 +12,7 @@ Before:
After:
Restore
- silent execute 'cd ' . fnameescape(g:dir)
- " Set the file to something else,
- " or we'll cause issues when running other tests
- silent file 'dummy.py'
- unlet! g:dir
+ call ale#test#RestoreDirectory()
Execute(The isort callback should return the correct default values):
AssertEqual
diff --git a/test/fixers/test_puppetlint_fixer_callback.vader b/test/fixers/test_puppetlint_fixer_callback.vader
index 398f61dc..04a85e56 100644
--- a/test/fixers/test_puppetlint_fixer_callback.vader
+++ b/test/fixers/test_puppetlint_fixer_callback.vader
@@ -6,7 +6,7 @@ Before:
let g:ale_puppet_puppetlint_executable = 'xxxinvalid'
let g:ale_puppet_puppetlint_options = '--invalid'
- silent! execute 'cd /testplugin/test/command_callback'
+ call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd ..
silent cd command_callback
let g:dir = getcwd()
@@ -14,11 +14,7 @@ Before:
After:
Restore
- silent execute 'cd ' . fnameescape(g:dir)
- " Set the file to something else,
- " or we'll cause issues when running other tests
- silent file 'dummy.pp'
- unlet! g:dir
+ call ale#test#RestoreDirectory()
Execute(The puppetlint callback should return the correct default values):
silent execute 'file ' . fnameescape(g:dir . '/puppet_paths/dummy.pp')
diff --git a/test/fixers/test_rubocop_fixer_callback.vader b/test/fixers/test_rubocop_fixer_callback.vader
index 74160c73..e3383537 100644
--- a/test/fixers/test_rubocop_fixer_callback.vader
+++ b/test/fixers/test_rubocop_fixer_callback.vader
@@ -4,7 +4,7 @@ Before:
" Use an invalid global executable, so we don't match it.
let g:ale_ruby_rubocop_executable = 'xxxinvalid'
- silent! execute 'cd /testplugin/test/command_callback'
+ call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd ..
silent cd command_callback
let g:dir = getcwd()
@@ -12,11 +12,7 @@ Before:
After:
Restore
- silent execute 'cd ' . fnameescape(g:dir)
- " Set the file to something else,
- " or we'll cause issues when running other tests
- silent file 'dummy.rb'
- unlet! g:dir
+ call ale#test#RestoreDirectory()
Execute(The rubocop callback should return the correct default values):
call ale#test#SetFilename('ruby_paths/dummy.rb')
diff --git a/test/fixers/test_yapf_fixer_callback.vader b/test/fixers/test_yapf_fixer_callback.vader
index 0b88e4d8..2653fd18 100644
--- a/test/fixers/test_yapf_fixer_callback.vader
+++ b/test/fixers/test_yapf_fixer_callback.vader
@@ -4,7 +4,7 @@ Before:
" Use an invalid global executable, so we don't match it.
let g:ale_python_yapf_executable = 'xxxinvalid'
- silent! execute 'cd /testplugin/test/command_callback'
+ call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd ..
silent cd command_callback
let g:dir = getcwd()
@@ -12,11 +12,7 @@ Before:
After:
Restore
- silent execute 'cd ' . fnameescape(g:dir)
- " Set the file to something else,
- " or we'll cause issues when running other tests
- silent file 'dummy.py'
- unlet! g:dir
+ call ale#test#RestoreDirectory()
Execute(The yapf callback should return the correct default values):
AssertEqual
diff --git a/test/handler/test_cppcheck_handler.vader b/test/handler/test_cppcheck_handler.vader
index 51efad4e..f153b9b5 100644
--- a/test/handler/test_cppcheck_handler.vader
+++ b/test/handler/test_cppcheck_handler.vader
@@ -1,10 +1,8 @@
Before:
- silent! cd /testplugin/test/handler
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test/handler')
After:
- silent execute 'cd ' . fnameescape(g:dir)
- unlet! g:dir
+ call ale#test#RestoreDirectory()
Execute(Basic errors should be handled by cppcheck):
call ale#test#SetFilename('test.cpp')
diff --git a/test/handler/test_perl_handler.vader b/test/handler/test_perl_handler.vader
index 3ada9aa4..18c5d706 100644
--- a/test/handler/test_perl_handler.vader
+++ b/test/handler/test_perl_handler.vader
@@ -1,13 +1,10 @@
Before:
- silent! cd /testplugin/test/handler
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test/handler')
runtime ale_linters/perl/perl.vim
After:
- silent execute 'cd ' . fnameescape(g:dir)
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The Perl linter should ignore errors from other files):
diff --git a/test/handler/test_tslint_handler.vader b/test/handler/test_tslint_handler.vader
index 6da218b2..ae87c52e 100644
--- a/test/handler/test_tslint_handler.vader
+++ b/test/handler/test_tslint_handler.vader
@@ -1,13 +1,10 @@
Before:
runtime ale_linters/typescript/tslint.vim
- silent! cd /testplugin/test/handler
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test/handler')
After:
- silent execute 'cd ' . fnameescape(g:dir)
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The tslint handler should parse lines correctly):
diff --git a/test/test_c_import_paths.vader b/test/test_c_import_paths.vader
index a9206eda..fbc3d563 100644
--- a/test/test_c_import_paths.vader
+++ b/test/test_c_import_paths.vader
@@ -4,8 +4,7 @@ Before:
Save g:ale_cpp_gcc_options
Save g:ale_cpp_clang_options
- silent! cd /testplugin/test
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test')
let g:ale_c_gcc_options = ''
let g:ale_c_clang_options = ''
@@ -15,8 +14,7 @@ Before:
After:
Restore
- silent execute 'cd ' . fnameescape(g:dir)
- unlet! g:dir
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
" Run this only once for this series of tests. The cleanup Execute step
diff --git a/test/test_csslint_config_detection.vader b/test/test_csslint_config_detection.vader
index 7a783748..b4707dc0 100644
--- a/test/test_csslint_config_detection.vader
+++ b/test/test_csslint_config_detection.vader
@@ -1,17 +1,14 @@
Before:
- silent! cd /testplugin/test
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/css/csslint.vim
After:
- silent execute 'cd ' . g:dir
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(--config should be set when the .csslintrc file is found):
- new csslint-test-files/some-app/subdir/testfile.js
+ call ale#test#SetFilename('csslint-test-files/some-app/subdir/testfile.js')
AssertEqual
\ (
@@ -21,10 +18,8 @@ Execute(--config should be set when the .csslintrc file is found):
\ ),
\ ale_linters#css#csslint#GetCommand(bufnr(''))
- :q
-
Execute(--config should not be used when no .csslintrc file exists):
- new csslint-test-files/other-app/testfile.css
+ call ale#test#SetFilename('csslint-test-files/other-app/testfile.css')
AssertEqual
\ (
@@ -32,5 +27,3 @@ Execute(--config should not be used when no .csslintrc file exists):
\ . ' %t'
\ ),
\ ale_linters#css#csslint#GetCommand(bufnr(''))
-
- :q
diff --git a/test/test_eslint_executable_detection.vader b/test/test_eslint_executable_detection.vader
index 4f787367..30ae38d5 100644
--- a/test/test_eslint_executable_detection.vader
+++ b/test/test_eslint_executable_detection.vader
@@ -1,8 +1,7 @@
Before:
let g:ale_javascript_eslint_executable = 'eslint_d'
- silent! cd /testplugin/test
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/javascript/eslint.vim
@@ -11,62 +10,50 @@ After:
let g:ale_javascript_eslint_executable = 'eslint'
let g:ale_javascript_eslint_use_global = 0
- silent execute 'cd ' . g:dir
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(create-react-app directories should be detected correctly):
- silent noautocmd new eslint-test-files/react-app/subdir/testfile.js
+ call ale#test#SetFilename('eslint-test-files/react-app/subdir/testfile.js')
AssertEqual
\ g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js',
\ ale#handlers#eslint#GetExecutable(bufnr(''))
- :q
-
Execute(use-global should override create-react-app detection):
let g:ale_javascript_eslint_use_global = 1
- silent noautocmd new eslint-test-files/react-app/subdir/testfile.js
+ call ale#test#SetFilename('eslint-test-files/react-app/subdir/testfile.js')
AssertEqual
\ 'eslint_d',
\ ale#handlers#eslint#GetExecutable(bufnr(''))
- :q
-
Execute(other app directories should be detected correctly):
- silent noautocmd new eslint-test-files/other-app/subdir/testfile.js
+ call ale#test#SetFilename('eslint-test-files/other-app/subdir/testfile.js')
AssertEqual
\ g:dir . '/eslint-test-files/node_modules/.bin/eslint',
\ ale#handlers#eslint#GetExecutable(bufnr(''))
- :q
-
Execute(use-global should override other app directories):
let g:ale_javascript_eslint_use_global = 1
- silent noautocmd new eslint-test-files/other-app/subdir/testfile.js
+ call ale#test#SetFilename('eslint-test-files/other-app/subdir/testfile.js')
AssertEqual
\ 'eslint_d',
\ ale#handlers#eslint#GetExecutable(bufnr(''))
- :q
-
Execute(eslint_d should be detected correctly):
- silent noautocmd new eslint-test-files/app-with-eslint-d/testfile.js
+ call ale#test#SetFilename('eslint-test-files/app-with-eslint-d/testfile.js')
AssertEqual
\ g:dir . '/eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d',
\ ale#handlers#eslint#GetExecutable(bufnr(''))
- :q
-
Execute(eslint.js executables should be run with node on Windows):
- silent noautocmd new eslint-test-files/react-app/subdir/testfile.js
+ call ale#test#SetFilename('eslint-test-files/react-app/subdir/testfile.js')
let g:ale_has_override['win32'] = 1
" We have to execute the file with node.
diff --git a/test/test_foodcritic_command_callback.vader b/test/test_foodcritic_command_callback.vader
index 32beb926..a5b02e49 100644
--- a/test/test_foodcritic_command_callback.vader
+++ b/test/test_foodcritic_command_callback.vader
@@ -2,25 +2,17 @@ Before:
let g:ale_chef_foodcritic_options = '-t ~F011'
let g:ale_chef_foodcritic_executable = 'foodcritic'
- silent! cd /testplugin/test
- let g:dir = getcwd()
-
+ call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/chef/foodcritic.vim
After:
let g:ale_chef_foodcritic_options = ''
let g:ale_chef_foodcritic_executable = ''
- silent execute 'cd ' . g:dir
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(command line should be assembled correctly):
-
AssertEqual
\ 'foodcritic -t \~F011 %t',
\ ale_linters#chef#foodcritic#GetCommand(bufnr(''))
-
- :q
-
diff --git a/test/test_phpcs_executable_detection.vader b/test/test_phpcs_executable_detection.vader
index 72b7af0b..786d3249 100644
--- a/test/test_phpcs_executable_detection.vader
+++ b/test/test_phpcs_executable_detection.vader
@@ -5,17 +5,14 @@ Before:
let g:ale_php_phpcs_executable = 'phpcs_test'
let g:ale_php_phpcs_use_global = 0
- silent! cd /testplugin/test
- let g:dir = getcwd()
+ call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/php/phpcs.vim
After:
Restore
- silent execute 'cd ' . fnameescape(g:dir)
- unlet! g:dir
-
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(project with phpcs should use local by default):