summaryrefslogtreecommitdiffstats
path: root/scripts/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xscripts/test12
-rw-r--r--scripts/test_extensions.vim197
-rw-r--r--scripts/test_filetypes.vim46
3 files changed, 241 insertions, 14 deletions
diff --git a/scripts/test b/scripts/test
index 88a2e973..97480439 100755
--- a/scripts/test
+++ b/scripts/test
@@ -2,12 +2,10 @@
set -e
-vim --clean -N --cmd "
- filetype plugin indent on
- syntax enable
+vim --clean -N -u <(echo "
let &rtp='$PWD,'.&rtp
- source ftdetect/polyglot.vim
+ let g:polyglot_test = 1
source scripts/test_extensions.vim
- source scripts/test_filetypes.vim
- exec ':q!'
-"
+ \"source scripts/test_filetypes.vim
+ qa!
+")
diff --git a/scripts/test_extensions.vim b/scripts/test_extensions.vim
index c7a22025..cb52bef8 100644
--- a/scripts/test_extensions.vim
+++ b/scripts/test_extensions.vim
@@ -1,16 +1,209 @@
function! TestExtension(filetype, filename, content)
try
- exec "e " . a:filename
+ let g:message = ""
+ exec "noautocmd n " . a:filename
+ put =a:content
+ 1delete _
+ filetype detect
exec "if &filetype != '" . a:filetype . "' \nthrow &filetype\nendif"
+ exec ":bw!"
catch
+ echo g:message
echo 'Filename "' . a:filename . '" does not resolve to extension "' . a:filetype . '"'
echo ' instead received: "' . v:exception . '"'
exec ':cq!'
endtry
endfunction
+call TestExtension('sh', 'bash1', "#!/bin/bash")
+call TestExtension('sh', 'bash2', "#! /bin/bash")
+call TestExtension('sh', 'bash3', "#! /bin/bash2.3")
+call TestExtension('sh', 'bash4', "#!/usr/bin/env bash")
+call TestExtension('sh', 'bash6', "#!/usr/bin/env -i -=split-string foo=bar bash -l foo")
+call TestExtension('sh', 'bash1', "#!/bin/bash")
+
+" Vim help file
+call TestExtension('help', $VIMRUNTIME . '/doc/foobar.txt', '')
+
+" Abaqus or Trasys
+call TestExtension('abaqus', 'foobar.inp', "*HEADING\nFoobar")
+call TestExtension('trasys', 'foobar.inp', "MSC PATRAN\n* foobar\nHEADER SURFACE DATA\nBSC ENCLO1")
+
+" 8th (Firth-derivative)
+call TestExtension('8th', 'foobar.8th', '')
+call TestExtension('8th', 'foobar.8th', '')
+
+" A-A-P recipe
+call TestExtension('aap', 'foobar.aap', '')
+
+
+" A2ps printing utility
+call TestExtension('a2ps', '/etc/a2ps.cfg', '')
+call TestExtension('a2ps', '/usr/local/etc/a2ps.cfg', '')
+call TestExtension('a2ps', '/etc/a2ps/foobar.cfg', '')
+call TestExtension('a2ps', '/usr/local/etc/a2ps/foobar.cfg', '')
+call TestExtension('a2ps', '/tmp/a2psrc', '')
+call TestExtension('a2ps', '/tmp/.a2psrc', '')
+
+" ABAB/4
+call TestExtension('abap', 'foobar.abap', '')
+
+" ABC music notation
+call TestExtension('abc', 'foobar.abc', '')
+
+" ABEL
+call TestExtension('abel', 'foobar.abl', '')
+
+" AceDB
+call TestExtension('acedb', 'foobar.wrm', '')
+
+" Ada (83, 9X, 95)
+call TestExtension('ada', 'foobar.adb', '')
+call TestExtension('ada', 'foobar.ads', '')
+call TestExtension('ada', 'foobar.ada', '')
+call TestExtension('ada', 'foobar.gpr', '')
+
+" AHDL
+call TestExtension('ahdl', 'foobar.tdf', '')
+
+" AIDL
+call TestExtension('aidl', 'foobar.aidl', '')
+
+" AMPL
+call TestExtension('ampl', 'foobar.run', '')
+
+" Ant
+call TestExtension('ant', 'build.xml', '')
+
+" Arduino
+call TestExtension('arduino', 'foobar.ino', '')
+call TestExtension('arduino', 'foobar.pde', '')
+
+" Apache config file
+call TestExtension('apache', '.htaccess', '')
+call TestExtension('apache', '/etc/httpd/foobar.conf', '')
+call TestExtension('apache', '/etc/apache2/sites-foobar/foobar.com', '')
+call TestExtension('apache', '/usr/local/etc/httpd/foobar.conf', '')
+call TestExtension('apache', '/usr/local/etc/apache2/sites-foobar/foobar.com', '')
+
+" XA65 MOS6510 cross assembler
+call TestExtension('a65', 'foobar.a65', '')
+
+" Applescript
+call TestExtension('applescript', 'foobar.scpt', '')
+
+" Applix ELF
+call TestExtension('elf', 'foobar.am', '')
+call TestExtension('automake', 'Makefile.am', '')
+call TestExtension('automake', 'makefile.am', '')
+
+" ALSA configuration
+call TestExtension('alsaconf', '.asoundrc', '')
+call TestExtension('alsaconf', '/usr/share/alsa/alsa.conf', '')
+call TestExtension('alsaconf', '/media/foo/usr/share/alsa/alsa.conf', '')
+call TestExtension('alsaconf', '/etc/asound.conf', '')
+call TestExtension('alsaconf', '/media/foo/etc/asound.conf', '')
+
+" Arc Macro Language
+call TestExtension('aml', 'foobar.aml', '')
+
+" APT config file
+call TestExtension('aptconf', 'apt.conf', '')
+call TestExtension('aptconf', '/root/.aptitude/config', '')
+call TestExtension('aptconf', '/etc/apt/apt.conf.d/foo_bar-12', '')
+call TestExtension('aptconf', '/etc/apt/apt.conf.d/foo_bar-12.conf', '')
+call TestExtension('', '/etc/apt/apt.conf.d/.gsdf', '')
+
+" Arch Inventory file
+call TestExtension('arch', '.arch-inventory', '')
+call TestExtension('arch', '=tagging-method', '')
+
+" ART*Enterprise (formerly ART-IM)
+call TestExtension('art', 'foobar.art', '')
+
+" AsciiDoc
+call TestExtension('asciidoc', 'foobar.asciidoc', '')
+call TestExtension('asciidoc', 'foobar.adoc', '')
+
+" ASN.1
+call TestExtension('asn', 'foobar.asn', '')
+call TestExtension('asn', 'foobar.asn1', '')
+
+" Active Server Pages (with Visual Basic Script)
+call TestExtension('aspvbs', 'foobar.asa', '')
+let g:filetype_asa = 'fizfuz'
+call TestExtension('fizfuz', 'foobar.asa', '')
+
+" Active Server Pages (with Perl or Visual Basic Script)
+call TestExtension('aspvbs', 'vbs.asp', "")
+call TestExtension('aspperl', 'perl.asp', "<Job ID=\"DropFiles\">\n<script language=\"PerlScript\">\n</script>\n</Job>")
+let g:filetype_asp = 'fizfuz'
+call TestExtension('fizfuz', 'fizfuz.asp', '')
+
+
+" Grub (must be before catch *.lst)
+call TestExtension('grub', '/boot/grub/menu.lst', '')
+call TestExtension('grub', '/media/foobar/boot/grub/menu.lst', '')
+call TestExtension('grub', '/boot/grub/grub.conf', '')
+call TestExtension('grub', '/media/foobar/boot/grub/grub.conf', '')
+call TestExtension('grub', '/etc/grub.conf', '')
+call TestExtension('grub', '/media/foobar/etc/grub.conf', '')
+
+" Assembly (all kinds)
+" *.lst is not pure assembly, it has two extra columns (address, byte codes)
+
+au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call dist#ft#FTasm()
+
+" Macro (VAX)
+call TestExtension('vmasm', 'foobar.mar', '')
+
+" Atlas
+call TestExtension('atlas', 'foobar.atl', '')
+call TestExtension('atlas', 'foobar.as', '')
+
+" Autoit v3
+call TestExtension('autoit', 'foobar.au3', '')
+
+" Autohotkey
+call TestExtension('autohotkey', 'foobar.ahk', '')
+
+" Automake
+call TestExtension('automake', 'Makefile.am', '')
+call TestExtension('automake', 'makefile.am', '')
+call TestExtension('automake', 'GNUmakefile.am', '')
+
+" Autotest .at files are actually m4
+call TestExtension('m4', 'foobar.at', '')
+
+" Avenue
+call TestExtension('ave', 'foobar.ave', '')
+
+" Awk
+call TestExtension('awk', 'foobar.awk', '')
+
+" vim-polyglot only
call TestExtension('blade', 'test.blade.php', '')
call TestExtension('yaml.ansible', 'playbook.yml', '')
call TestExtension('yaml.ansible', 'host_vars/foobar', '')
-call TestExtension('yaml.ansible', 'handlers.foo.yaml', '')
+call TestExtension('yaml.ansible', 'handlers.foobar.yaml', '')
call TestExtension('yaml.ansible', 'requirements.yaml', '')
+call TestExtension('ps1xml', 'foobar.ps1xml', '')
+
+" .m extension
+call TestExtension('octave', 'matlab.m', '')
+call TestExtension('objc', 'objc.m', "\n\n #import <Foundation/Foundation.h>")
+call TestExtension('octave', 'objc.m', "results_ub_times=zeros(2,2,M);\n%results pour la lower bound")
+call TestExtension('mma', 'mathematica.m', "newcase[ \"00003\" ];\n (* Hello world *)")
+call TestExtension('murphi', 'murphi.m', "type\n square: 1 .. 9")
+call TestExtension('murphi', 'murphi.m', "something\n--foobar")
+call TestExtension('octave', 'percentcomment.m', "hello world\n%foobar")
+call TestExtension('objc', 'comment.m', "\n/* Hello world */")
+let g:filetype_m = 'fizfuz'
+call TestExtension('fizfuz', 'fizfuz.m', '')
+
+" .fs extension
+call TestExtension('forth', 'empty.fs', '')
+call TestExtension('fsharp', 'fsharp.fs', "let myInt = 5")
+call TestExtension('glsl', 'glsl.fs', "//#version 120\nvoid main() {}")
+let g:filetype_fs = 'fizfuz'
+call TestExtension('fizfuz', 'fizfuz.fs', '')
diff --git a/scripts/test_filetypes.vim b/scripts/test_filetypes.vim
index 53a21af4..a9bae396 100644
--- a/scripts/test_filetypes.vim
+++ b/scripts/test_filetypes.vim
@@ -10,12 +10,40 @@ function! TestFiletype(filetype)
endtry
endfunction
+call TestFiletype('8th')
+call TestFiletype('a2ps')
+call TestFiletype('a65')
+call TestFiletype('aap')
+call TestFiletype('abap')
+call TestFiletype('abaqus')
+call TestFiletype('abc')
+call TestFiletype('abel')
+call TestFiletype('acedb')
call TestFiletype('asl')
+call TestFiletype('ada')
+call TestFiletype('ahdl')
+call TestFiletype('aidl')
+call TestFiletype('alsaconf')
+call TestFiletype('aml')
+call TestFiletype('ampl')
+call TestFiletype('ant')
+call TestFiletype('apache')
call TestFiletype('apiblueprint')
call TestFiletype('applescript')
+call TestFiletype('aptconf')
+call TestFiletype('arch')
call TestFiletype('arduino')
+call TestFiletype('art')
call TestFiletype('asciidoc')
call TestFiletype('autohotkey')
+call TestFiletype('automake')
+call TestFiletype('asn')
+call TestFiletype('aspvbs')
+call TestFiletype('aspperl')
+call TestFiletype('atlas')
+call TestFiletype('autoit')
+call TestFiletype('ave')
+call TestFiletype('awk')
call TestFiletype('c')
call TestFiletype('cpp')
call TestFiletype('caddyfile')
@@ -32,6 +60,7 @@ call TestFiletype('cucumber')
call TestFiletype('cuesheet')
call TestFiletype('dart')
call TestFiletype('dhall')
+call TestFiletype('grub')
call TestFiletype('d')
call TestFiletype('dcov')
call TestFiletype('dd')
@@ -39,6 +68,7 @@ call TestFiletype('ddoc')
call TestFiletype('dsdl')
call TestFiletype('Dockerfile')
call TestFiletype('yaml.docker-compose')
+call TestFiletype('elf')
call TestFiletype('elixir')
call TestFiletype('eelixir')
call TestFiletype('elm')
@@ -49,6 +79,7 @@ call TestFiletype('fennel')
call TestFiletype('ferm')
call TestFiletype('fish')
call TestFiletype('fbs')
+call TestFiletype('forth')
call TestFiletype('fsharp')
call TestFiletype('gdscript3')
call TestFiletype('gitconfig')
@@ -95,13 +126,16 @@ call TestFiletype('llvm')
call TestFiletype('tablegen')
call TestFiletype('log')
call TestFiletype('lua')
+call TestFiletype('m4')
call TestFiletype('mako')
+call TestFiletype('octave')
call TestFiletype('mma')
call TestFiletype('markdown')
call TestFiletype('markdown.mdx')
call TestFiletype('meson')
call TestFiletype('dosini')
call TestFiletype('moon')
+call TestFiletype('murphi')
call TestFiletype('nginx')
call TestFiletype('nim')
call TestFiletype('nix')
@@ -115,17 +149,16 @@ call TestFiletype('ocamlbuild_tags')
call TestFiletype('ocpbuild')
call TestFiletype('ocpbuildroot')
call TestFiletype('sexplib')
-call TestFiletype('octave')
call TestFiletype('opencl')
call TestFiletype('perl')
call TestFiletype('sql')
call TestFiletype('sql')
call TestFiletype('cql')
-call TestFiletype('php')
call TestFiletype('blade')
+call TestFiletype('php')
call TestFiletype('plantuml')
call TestFiletype('pony')
-call TestFiletype('powershell')
+call TestFiletype('ps1')
call TestFiletype('ps1xml')
call TestFiletype('proto')
call TestFiletype('pug')
@@ -181,13 +214,16 @@ call TestFiletype('vala')
call TestFiletype('vbnet')
call TestFiletype('vcl')
call TestFiletype('velocity')
+call TestFiletype('vmasm')
call TestFiletype('vue')
call TestFiletype('xdc')
call TestFiletype('xml')
call TestFiletype('xsl')
-call TestFiletype('yaml')
call TestFiletype('yaml.ansible')
+call TestFiletype('yaml')
call TestFiletype('helm')
+call TestFiletype('help')
call TestFiletype('zephir')
-call TestFiletype('zig')
call TestFiletype('zir')
+call TestFiletype('zig')
+call TestFiletype('trasys')