mirror of
https://github.com/sheerun/vim-polyglot.git
synced 2025-11-08 11:33:52 -05:00
Update test script to ruby
This commit is contained in:
2
Makefile
2
Makefile
@@ -7,4 +7,4 @@ test:
|
|||||||
@ scripts/test
|
@ scripts/test
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
@ echo "packages.yaml\nheuristics.yaml\nscripts/test\nscripts/build\nscripts/test_extensions.vim" | DEV=1 entr bash -c 'make && make test'
|
@ echo "packages.yaml\nheuristics.yaml\nscripts/test\nscripts/build\ntests/extensions.vim" | DEV=1 entr bash -c 'make && make test'
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ let s:cpo_save = &cpoptions
|
|||||||
set cpoptions&vim
|
set cpoptions&vim
|
||||||
|
|
||||||
setlocal nolisp
|
setlocal nolisp
|
||||||
setlocal autoindent shiftwidth=2 tabstop=2 softtabstop=2
|
setlocal autoindent shiftwidth=2 tabstop=2 softtabstop=2 expandtab
|
||||||
setlocal indentexpr=TerraformIndent(v:lnum)
|
setlocal indentexpr=TerraformIndent(v:lnum)
|
||||||
setlocal indentkeys+=<:>,0=},0=)
|
setlocal indentkeys+=<:>,0=},0=)
|
||||||
let b:undo_indent = 'setlocal lisp< autoindent< shiftwidth< tabstop< softtabstop<'
|
let b:undo_indent = 'setlocal lisp< autoindent< shiftwidth< tabstop< softtabstop<'
|
||||||
\ . ' indentexpr< indentkeys<'
|
\ . ' expandtab< indentexpr< indentkeys<'
|
||||||
|
|
||||||
let &cpoptions = s:cpo_save
|
let &cpoptions = s:cpo_save
|
||||||
unlet s:cpo_save
|
unlet s:cpo_save
|
||||||
|
|||||||
@@ -643,15 +643,10 @@ end
|
|||||||
def generate_tests(packages)
|
def generate_tests(packages)
|
||||||
output = <<~EOS
|
output = <<~EOS
|
||||||
function! TestFiletype(filetype)
|
function! TestFiletype(filetype)
|
||||||
try
|
call Log('Loading ' . a:filetype . ' filetype...')
|
||||||
enew
|
|
||||||
exec 'set ft=' . a:filetype
|
enew
|
||||||
catch
|
exec 'set ft=' . a:filetype
|
||||||
echo 'Error loading filetype ' . a:filetype . ':'
|
|
||||||
echo v:exception
|
|
||||||
echo v:throwpoint
|
|
||||||
exec ':cq!'
|
|
||||||
endtry
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
EOS
|
EOS
|
||||||
@@ -662,7 +657,7 @@ def generate_tests(packages)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
File.write('scripts/test_filetypes.vim', output)
|
File.write('tests/filetypes.vim', output)
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
70
scripts/test
70
scripts/test
@@ -1,16 +1,60 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
set -e
|
def run_script(src)
|
||||||
|
system("bash", "-c", src)
|
||||||
|
end
|
||||||
|
|
||||||
vim --clean -N -u <(echo "
|
def run_vimscript(src)
|
||||||
let &rtp='$PWD,'.&rtp
|
wrapper = <<~EOF
|
||||||
let g:polyglot_test = 1
|
vim --clean --not-a-term -u <(cat <<- "EOM"
|
||||||
source tests/extensions.vim
|
let g:polyglot_test = 1
|
||||||
source tests/filetypes.vim
|
let &rtp='$PWD,' . &rtp
|
||||||
qa!
|
runtime filetype.vim
|
||||||
")
|
set t_ti= t_te=
|
||||||
|
set shortmess+=F
|
||||||
|
set noswapfile
|
||||||
|
set nocp
|
||||||
|
set nomore
|
||||||
|
func! Log(msg)
|
||||||
|
if $DEV != '1'
|
||||||
|
echo a:msg
|
||||||
|
else
|
||||||
|
echon '.'
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
EOM
|
||||||
|
) -S <(cat <<- "EOM"
|
||||||
|
try
|
||||||
|
#{src}
|
||||||
|
catch
|
||||||
|
echo v:exception
|
||||||
|
echo v:throwpoint
|
||||||
|
endtry
|
||||||
|
qa!
|
||||||
|
EOM
|
||||||
|
) | perl -pe 's/\e\[[0-9;]*[a-zA-Z]//g'
|
||||||
|
EOF
|
||||||
|
|
||||||
if ! expect -c 'set timeout 1' -c 'spawn vim -N --clean -c "set nomore | :helptags ./doc | q"' -c 'expect "ENTER" { exit 1 }' > /dev/null; then
|
run_script(wrapper)
|
||||||
echo "Please ensure ':helptags ./doc' works properly"
|
end
|
||||||
exit 1
|
|
||||||
fi
|
test_helptags = <<~EOF
|
||||||
|
if ! expect -c 'set timeout 1' -c 'spawn vim -N --clean -c "set nomore | :helptags ./doc | q"' -c 'expect "ENTER" { exit 1 }' > /dev/null; then
|
||||||
|
echo "Please ensure ':helptags ./doc' works properly"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
run_vimscript('source tests/filetypes.vim')
|
||||||
|
run_vimscript('source tests/extensions.vim')
|
||||||
|
run_script(test_helptags)
|
||||||
|
|
||||||
|
# run_vimscript("
|
||||||
|
# func! TestIndent(file)
|
||||||
|
# :e a:file
|
||||||
|
# echo 'ok'
|
||||||
|
# echo &filetype
|
||||||
|
# endfunc
|
||||||
|
#
|
||||||
|
# #{Dir['tests/indent/**/test.*'].map { |f| "call TestIndent(\"#{f}\")"}.join("\n")}
|
||||||
|
# ")
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
function! TestFiletype(filetype)
|
function! TestFiletype(filetype)
|
||||||
|
call Log('Loading ' . a:filetype . ' filetype...')
|
||||||
|
|
||||||
try
|
try
|
||||||
enew
|
enew
|
||||||
exec 'set ft=' . a:filetype
|
exec 'set ft=' . a:filetype
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
function! TestExtension(filetype, filename, content)
|
function! TestExtension(filetype, filename, content)
|
||||||
|
call Log('Detecting ' . a:filetype . ' filetype (' . a:filename . ')...')
|
||||||
|
|
||||||
try
|
try
|
||||||
let g:message = ""
|
let g:message = ""
|
||||||
exec "noautocmd n " . a:filename
|
exec "noautocmd n " . a:filename
|
||||||
put =a:content
|
silent put =a:content
|
||||||
1delete _
|
1delete _
|
||||||
filetype detect
|
filetype detect
|
||||||
exec "if &filetype != '" . a:filetype . "' \nthrow &filetype\nendif"
|
exec "if &filetype != '" . a:filetype . "' \nthrow &filetype\nendif"
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
function! TestFiletype(filetype)
|
function! TestFiletype(filetype)
|
||||||
try
|
call Log('Loading ' . a:filetype . ' filetype...')
|
||||||
enew
|
|
||||||
exec 'set ft=' . a:filetype
|
enew
|
||||||
catch
|
exec 'set ft=' . a:filetype
|
||||||
echo 'Error loading filetype ' . a:filetype . ':'
|
|
||||||
echo v:exception
|
|
||||||
echo v:throwpoint
|
|
||||||
exec ':cq!'
|
|
||||||
endtry
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
call TestFiletype('8th')
|
call TestFiletype('8th')
|
||||||
|
|||||||
10
tests/indent/2.1/test.js
Normal file
10
tests/indent/2.1/test.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// File with 2-spaces indentation
|
||||||
|
function foobar() {
|
||||||
|
foo = bar
|
||||||
|
while (true) {
|
||||||
|
fizfuz()
|
||||||
|
fizfuz()
|
||||||
|
fizfuz()
|
||||||
|
fizfuz()
|
||||||
|
}
|
||||||
|
}
|
||||||
10
tests/indent/4.1/test.js
Normal file
10
tests/indent/4.1/test.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// File with 4-spaces indentation
|
||||||
|
function foobar() {
|
||||||
|
foo = bar
|
||||||
|
while (true) {
|
||||||
|
fizfuz()
|
||||||
|
fizfuz()
|
||||||
|
fizfuz()
|
||||||
|
fizfuz()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user