summaryrefslogtreecommitdiff
path: root/test/fixers
diff options
context:
space:
mode:
authorBartek thindil Jasicki <thindil@laeran.pl>2020-08-14 19:38:09 +0200
committerBartek thindil Jasicki <thindil@laeran.pl>2020-08-14 19:38:09 +0200
commit04bd84e914af02e1c7d61ccf8f8368de85eab30e (patch)
treeda622d456ce01358a85a680f9fc8d802bc61ff01 /test/fixers
parent973c4ea053f78d4daa6eceff36da0bbecd788077 (diff)
parent5ceda0164c5fae0d61fd51d4c9e083b27abdc9d2 (diff)
downloadale-04bd84e914af02e1c7d61ccf8f8368de85eab30e.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'test/fixers')
-rw-r--r--test/fixers/test_prettier_standard_callback.vader19
-rw-r--r--test/fixers/test_rubocop_fixer_callback.vader68
-rw-r--r--test/fixers/test_tslint_fixer_callback.vader4
3 files changed, 83 insertions, 8 deletions
diff --git a/test/fixers/test_prettier_standard_callback.vader b/test/fixers/test_prettier_standard_callback.vader
new file mode 100644
index 00000000..ab33fe20
--- /dev/null
+++ b/test/fixers/test_prettier_standard_callback.vader
@@ -0,0 +1,19 @@
+Before:
+ call ale#assert#SetUpFixerTest('javascript', 'prettier_standard')
+
+ silent cd ..
+ silent cd command_callback
+ let g:dir = getcwd()
+
+After:
+ call ale#assert#TearDownFixerTest()
+
+Execute(The prettier callback should return the correct default values):
+ call ale#test#SetFilename('../prettier-test-files/testfile.js')
+
+ AssertFixer
+ \ {
+ \ 'command': ale#Escape(g:ale_javascript_prettier_standard_executable)
+ \ . ' --stdin'
+ \ . ' --stdin-filepath=%s ',
+ \ }
diff --git a/test/fixers/test_rubocop_fixer_callback.vader b/test/fixers/test_rubocop_fixer_callback.vader
index 866326bf..305881e0 100644
--- a/test/fixers/test_rubocop_fixer_callback.vader
+++ b/test/fixers/test_rubocop_fixer_callback.vader
@@ -21,9 +21,10 @@ Execute(The rubocop callback should return the correct default values):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
- \ . ' --auto-correct --force-exclusion %t',
+ \ . ' --auto-correct --force-exclusion --stdin '
+ \ . ale#Escape(expand('#' . bufnr('') . ':p')),
\ },
\ ale#fixers#rubocop#Fix(bufnr(''))
@@ -32,10 +33,11 @@ Execute(The rubocop callback should include configuration files):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
\ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml'))
- \ . ' --auto-correct --force-exclusion %t',
+ \ . ' --auto-correct --force-exclusion --stdin '
+ \ . ale#Escape(expand('#' . bufnr('') . ':p')),
\ },
\ ale#fixers#rubocop#Fix(bufnr(''))
@@ -45,10 +47,64 @@ Execute(The rubocop callback should include custom rubocop options):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
\ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml'))
\ . ' --except Lint/Debugger'
- \ . ' --auto-correct --force-exclusion %t',
+ \ . ' --auto-correct --force-exclusion --stdin '
+ \ . ale#Escape(expand('#' . bufnr('') . ':p')),
\ },
\ ale#fixers#rubocop#Fix(bufnr(''))
+
+Execute(The rubocop callback should use auto-correct-all option when set):
+ let g:ale_ruby_rubocop_auto_correct_all = 1
+ call ale#test#SetFilename('ruby_paths/with_config/dummy.rb')
+
+ AssertEqual
+ \ {
+ \ 'process_with': 'ale#fixers#rubocop#PostProcess',
+ \ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
+ \ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml'))
+ \ . ' --auto-correct-all --force-exclusion --stdin '
+ \ . ale#Escape(expand('#' . bufnr('') . ':p')),
+ \ },
+ \ ale#fixers#rubocop#Fix(bufnr(''))
+
+Execute(The rubocop post-processor should remove diagnostics content):
+ AssertEqual
+ \ [
+ \ 'class MyModel < ApplicationRecord',
+ \ ' # rubocop:disable Rails/InverseOf',
+ \ ' has_one :something',
+ \ ' # rubocop:enable Rails/InverseOf',
+ \ 'end',
+ \ '',
+ \ 'array = [1, 2, 3,',
+ \ ' 4, 5, 6]',
+ \ 'array = [''run'',',
+ \ ' ''forrest'',',
+ \ ' ''run'']',
+ \ ],
+ \ ale#fixers#rubocop#PostProcess(bufnr(''), [
+ \ 'Inspecting 1 file',
+ \ 'C',
+ \ '',
+ \ 'Offenses:',
+ \ 'app/models/my_model.rb:8:3: C: [Corrected] Layout/ArrayAlignment: ',
+ \ '4, 5, 6]',
+ \ '^',
+ \ '',
+ \ '1 file inspected, 3 offenses detected, 3 offenses corrected',
+ \ '====================',
+ \ 'class MyModel < ApplicationRecord',
+ \ ' # rubocop:disable Rails/InverseOf',
+ \ ' has_one :something',
+ \ ' # rubocop:enable Rails/InverseOf',
+ \ 'end',
+ \ '',
+ \ 'array = [1, 2, 3,',
+ \ ' 4, 5, 6]',
+ \ 'array = [''run'',',
+ \ ' ''forrest'',',
+ \ ' ''run'']',
+ \ ])
diff --git a/test/fixers/test_tslint_fixer_callback.vader b/test/fixers/test_tslint_fixer_callback.vader
index aa9c0322..a88992fa 100644
--- a/test/fixers/test_tslint_fixer_callback.vader
+++ b/test/fixers/test_tslint_fixer_callback.vader
@@ -27,7 +27,7 @@ Execute(The tslint callback should return the correct default values):
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('tslint')
\ . ' -c ' . ale#Escape('tslint.json')
- \ . ' --fix %t',
+ \ . ' --outputAbsolutePaths --fix %t',
\ },
\ ale#fixers#tslint#Fix(bufnr(''))
@@ -40,6 +40,6 @@ Execute(The tslint callback should include custom tslint config option):
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('tslint')
\ . ' -c ' . ale#Escape('.tslintrc')
- \ . ' --fix %t',
+ \ . ' --outputAbsolutePaths --fix %t',
\ },
\ ale#fixers#tslint#Fix(bufnr(''))