blob: 1ce2718278dddded760e8f5b0fa553e4846e1f69 [file] [log] [blame]
Bram Moolenaar10561fe2018-05-19 15:01:10 +02001" Test the :compiler command
2
Bram Moolenaar5a4c3082019-12-01 15:23:11 +01003source check.vim
4
Bram Moolenaar10561fe2018-05-19 15:01:10 +02005func Test_compiler()
6 if !executable('perl')
7 return
8 endif
Bram Moolenaar5a4c3082019-12-01 15:23:11 +01009 CheckFeature quickfix
Bram Moolenaar10561fe2018-05-19 15:01:10 +020010
Bram Moolenaarf0447e82018-07-03 21:26:38 +020011 " $LANG changes the output of Perl.
12 if $LANG != ''
13 unlet $LANG
14 endif
15
Bram Moolenaardff2adc2019-07-31 22:18:22 +020016 " %:S does not work properly with 'shellslash' set
17 let save_shellslash = &shellslash
18 set noshellslash
19
Bram Moolenaar10561fe2018-05-19 15:01:10 +020020 e Xfoo.pl
21 compiler perl
22 call assert_equal('perl', b:current_compiler)
23 call assert_fails('let g:current_compiler', 'E121:')
24
25 call setline(1, ['#!/usr/bin/perl -w', 'use strict;', 'my $foo=1'])
26 w!
27 call feedkeys(":make\<CR>\<CR>", 'tx')
28 call assert_fails('clist', 'E42:')
29
30 call setline(1, ['#!/usr/bin/perl -w', 'use strict;', '$foo=1'])
31 w!
32 call feedkeys(":make\<CR>\<CR>", 'tx')
33 let a=execute('clist')
Bram Moolenaarcebfcff2019-09-18 21:42:38 +020034 call assert_match('\n \d\+ Xfoo.pl:3: Global symbol "$foo" '
35 \ . 'requires explicit package name', a)
36
Bram Moolenaar10561fe2018-05-19 15:01:10 +020037
Bram Moolenaardff2adc2019-07-31 22:18:22 +020038 let &shellslash = save_shellslash
Bram Moolenaar10561fe2018-05-19 15:01:10 +020039 call delete('Xfoo.pl')
40 bw!
41endfunc
42
43func Test_compiler_without_arg()
Bram Moolenaarc25e7022019-10-10 14:08:26 +020044 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
45 let a = split(execute('compiler'))
46 call assert_match(runtime .. '/compiler/ant.vim$', a[0])
47 call assert_match(runtime .. '/compiler/bcc.vim$', a[1])
48 call assert_match(runtime .. '/compiler/xmlwf.vim$', a[-1])
Bram Moolenaar10561fe2018-05-19 15:01:10 +020049endfunc
50
51func Test_compiler_completion()
52 call feedkeys(":compiler \<C-A>\<C-B>\"\<CR>", 'tx')
53 call assert_match('^"compiler ant bcc .* xmlwf$', @:)
54
55 call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx')
56 call assert_equal('"compiler pbx perl php pylint pyunit', @:)
57
58 call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx')
59 call assert_equal('"compiler! pbx perl php pylint pyunit', @:)
60endfunc
61
62func Test_compiler_error()
63 call assert_fails('compiler doesnotexist', 'E666:')
64endfunc