diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/elixir-test-files/testfile.ex | 0 | ||||
-rw-r--r-- | test/fixers/test_hfmt_fixer_callback.vader | 24 | ||||
-rw-r--r-- | test/fixers/test_mix_format_fixer_callback.vader | 20 | ||||
-rw-r--r-- | test/fixers/test_rustfmt_fixer_callback.vader | 38 | ||||
-rw-r--r-- | test/handler/test_php_phan_handler.vader | 24 | ||||
-rw-r--r-- | test/rust_files/testfile.rs | 0 | ||||
-rwxr-xr-x | test/script/check-supported-tools-tables | 20 | ||||
-rwxr-xr-x | test/script/check-toc | 11 |
8 files changed, 122 insertions, 15 deletions
diff --git a/test/elixir-test-files/testfile.ex b/test/elixir-test-files/testfile.ex new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/elixir-test-files/testfile.ex diff --git a/test/fixers/test_hfmt_fixer_callback.vader b/test/fixers/test_hfmt_fixer_callback.vader new file mode 100644 index 00000000..69cd03f8 --- /dev/null +++ b/test/fixers/test_hfmt_fixer_callback.vader @@ -0,0 +1,24 @@ +Before: + Save g:ale_haskell_hfmt_executable + + " Use an invalid global executable, so we don't match it. + let g:ale_haskell_hfmt_executable = 'xxxinvalid' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The hfmt callback should return the correct default values): + call ale#test#SetFilename('../haskell_files/testfile.hs') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' -w' + \ . ' %t', + \ }, + \ ale#fixers#hfmt#Fix(bufnr('')) diff --git a/test/fixers/test_mix_format_fixer_callback.vader b/test/fixers/test_mix_format_fixer_callback.vader new file mode 100644 index 00000000..c6c97c57 --- /dev/null +++ b/test/fixers/test_mix_format_fixer_callback.vader @@ -0,0 +1,20 @@ +Before: + call ale#test#SetDirectory('/testplugin/test/fixers') + Save g:ale_elixir_mix_executable + + let g:ale_elixir_mix_executable = 'xxxinvalid' + +After: + call ale#test#RestoreDirectory() + +Execute(The mix_format callback should return the correct default values): + call ale#test#SetFilename('../elixir-test-files/testfile.ex') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' format %t', + \ }, + \ ale#fixers#mix_format#Fix(bufnr('')) + diff --git a/test/fixers/test_rustfmt_fixer_callback.vader b/test/fixers/test_rustfmt_fixer_callback.vader new file mode 100644 index 00000000..36dd58a1 --- /dev/null +++ b/test/fixers/test_rustfmt_fixer_callback.vader @@ -0,0 +1,38 @@ +Before: + Save g:ale_rust_rustfmt_executable + Save g:ale_rust_rustfmt_options + + " Use an invalid global executable, so we don't match it. + let g:ale_rust_rustfmt_executable = 'xxxinvalid' + let g:ale_rust_rustfmt_options = '' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The rustfmt callback should return the correct default values): + call ale#test#SetFilename('../rust_files/testfile.rs') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' %t', + \ }, + \ ale#fixers#rustfmt#Fix(bufnr('')) + +Execute(The rustfmt callback should include custom rustfmt options): + let g:ale_rust_rustfmt_options = "--skip-children" + call ale#test#SetFilename('../rust_files/testfile.rs') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' ' . g:ale_rust_rustfmt_options + \ . ' %t', + \ }, + \ ale#fixers#rustfmt#Fix(bufnr('')) diff --git a/test/handler/test_php_phan_handler.vader b/test/handler/test_php_phan_handler.vader new file mode 100644 index 00000000..68ed6d06 --- /dev/null +++ b/test/handler/test_php_phan_handler.vader @@ -0,0 +1,24 @@ +Before: + runtime ale_linters/php/phan.vim + +Execute(The php static analyzer handler should parse errors from phan): + AssertEqual + \ [ + \ { + \ 'lnum': 25, + \ 'type': 'W', + \ 'text': 'Return type of getValidator is undeclared type \Respect\Validation\Validator', + \ }, + \ { + \ 'lnum': 66, + \ 'type': 'W', + \ 'text': 'Call to method string from undeclared class \Respect\Validation\Validator', + \ }, + \ ], + \ ale_linters#php#phan#Handle(347, [ + \ "example.php:25 PhanUndeclaredTypeReturnType Return type of getValidator is undeclared type \\Respect\\Validation\\Validator", + \ "example.php:66 PhanUndeclaredClassMethod Call to method string from undeclared class \\Respect\\Validation\\Validator", + \ ]) + +After: + call ale#linter#Reset() diff --git a/test/rust_files/testfile.rs b/test/rust_files/testfile.rs new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/rust_files/testfile.rs diff --git a/test/script/check-supported-tools-tables b/test/script/check-supported-tools-tables index 1d0fec53..32cebb2d 100755 --- a/test/script/check-supported-tools-tables +++ b/test/script/check-supported-tools-tables @@ -30,30 +30,30 @@ readme_section_size="$( \ # shellcheck disable=SC2003 readme_end_line="$(expr "$readme_start_line" + "$readme_section_size")" -doc_file="$(mktemp)" -readme_file="$(mktemp)" +doc_file="$(mktemp -t doc.XXXXXXXX)" +readme_file="$(mktemp -t readme.XXXXXXXX)" sed -n "$ale_help_start_line,$ale_help_end_line"p doc/ale.txt \ | grep '\* .*: ' \ | sed 's/^*//' \ - | sed 's/[`!^]\|([^)]*)//g' \ + | sed 's/[`!^]//g;s/([^)]*)//g' \ | sed 's/ *\([,:]\)/\1/g' \ | sed 's/ */ /g' \ - | sed 's/^ *\| *$//g' \ + | sed 's/^ *//;s/ *$//' \ | sed 's/^/ /' \ > "$doc_file" sed -n "$readme_start_line,$readme_end_line"p README.md \ | grep '| .* |' \ - | sed '/^| Language\|^| ---/d' \ + | sed '/^| Language/d;/^| ---/d' \ | sed 's/^|//' \ - | sed 's/ \?|/:/' \ - | sed 's/[`!^|]\|([^)]*)//g' \ - | sed 's/\[\|\]//g' \ - | sed 's/see[^,]*\(,\|$\)/\1/g' \ + | sed 's/ \{0,1\}|/:/' \ + | sed 's/[`!^|]//g;s/([^)]*)//g' \ + | sed 's/\[//g;s/\]//g' \ + | sed 's/see[^,]*//g' \ | sed 's/ *\([,:]\)/\1/g' \ | sed 's/ */ /g' \ - | sed 's/^ *\| *$//g' \ + | sed 's/^ *//;s/ *$//' \ | sed 's/^/ /' \ | sed 's/ *-n flag//g' \ > "$readme_file" diff --git a/test/script/check-toc b/test/script/check-toc index c4512b08..426d5a1d 100755 --- a/test/script/check-toc +++ b/test/script/check-toc @@ -23,18 +23,19 @@ tagged_toc_file="$(mktemp -t ale.txt.XXXXXXXX)" sorted_toc_file="$(mktemp -t sorted-ale.txt.XXXXXXXX)" sed -n "$toc_start_line,$toc_end_line"p doc/ale.txt \ - | sed 's/^ \( *[^.]\+\)\.\+|\(.\+\)|/\1, \2/' \ + | sed 's/^ \( *[^.][^.]*\)\.\.*|\(..*\)|/\1, \2/' \ > "$toc_file" # Get all of the doc files in a natural sorted order. -doc_files="$(/bin/ls -1v doc | grep ^ale- | sed 's/^/doc\//' | paste -sd ' ')" +doc_files="$(/bin/ls -1v doc | grep ^ale- | sed 's/^/doc\//' | paste -sd ' ' -)" # shellcheck disable=SC2086 grep -h 'ale-.*-options\|^[a-z].*\*ale-.*\*$' $doc_files \ | sed 's/^/ /' \ | sed 's/ALE Shell Integration/ALE sh Integration/' \ - | sed 's/ ALE \(.*\) Integration/\L\1/' \ - | sed 's/ *\*\(.\+\)\*$/, \1/' \ + | sed 's/ ALE \(.*\) Integration/\1/' \ + | sed 's/ *\*\(..*\)\*$/, \1/' \ + | tr '[:upper:]' '[:lower:]' \ | sed 's/objective-c/objc/' \ | sed 's/c++/cpp/' \ > "$heading_file" @@ -62,7 +63,7 @@ while read -r; do done < "$toc_file" # Sort the sections and sub-sections and remove the tags. -sort -h "$tagged_toc_file" | sed 's/[0-9]\+ //' > "$sorted_toc_file" +sort -sn "$tagged_toc_file" | sed 's/[0-9][0-9]* //' > "$sorted_toc_file" echo 'Check for bad ToC sorting:' echo |