annotate src/testdir/test_compiler.vim @ 22981:72e0ec552189 v8.2.2037

patch 8.2.2037: compiler test depends on list of compiler plugins Commit: https://github.com/vim/vim/commit/60bc8e7244080b7ead009cfabebc3401f272ddbe Author: Bram Moolenaar <Bram@vim.org> Date: Mon Nov 23 21:24:58 2020 +0100 patch 8.2.2037: compiler test depends on list of compiler plugins Problem: Compiler test depends on list of compiler plugins. Solution: Compare with the actual list of compiler plugins.
author Bram Moolenaar <Bram@vim.org>
date Mon, 23 Nov 2020 21:30:04 +0100
parents 08940efa6b4e
children 1e1422df34e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Test the :compiler command
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
18767
068337e86133 patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents: 18273
diff changeset
3 source check.vim
19348
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19289
diff changeset
4 source shared.vim
18767
068337e86133 patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents: 18273
diff changeset
5
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 func Test_compiler()
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 if !executable('perl')
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 return
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 endif
18767
068337e86133 patch 8.1.2373: cannot build with +popupwin but without +quickfix
Bram Moolenaar <Bram@vim.org>
parents: 18273
diff changeset
10 CheckFeature quickfix
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11
14260
9ff35e144467 patch 8.1.0146: when $LANG is set the compiler test may fail
Christian Brabandt <cb@256bit.org>
parents: 13974
diff changeset
12 " $LANG changes the output of Perl.
9ff35e144467 patch 8.1.0146: when $LANG is set the compiler test may fail
Christian Brabandt <cb@256bit.org>
parents: 13974
diff changeset
13 if $LANG != ''
9ff35e144467 patch 8.1.0146: when $LANG is set the compiler test may fail
Christian Brabandt <cb@256bit.org>
parents: 13974
diff changeset
14 unlet $LANG
9ff35e144467 patch 8.1.0146: when $LANG is set the compiler test may fail
Christian Brabandt <cb@256bit.org>
parents: 13974
diff changeset
15 endif
9ff35e144467 patch 8.1.0146: when $LANG is set the compiler test may fail
Christian Brabandt <cb@256bit.org>
parents: 13974
diff changeset
16
17572
0d7c87cad133 patch 8.1.1783: MS-Windows: compiler test may fail when using %:S
Bram Moolenaar <Bram@vim.org>
parents: 14260
diff changeset
17 " %:S does not work properly with 'shellslash' set
0d7c87cad133 patch 8.1.1783: MS-Windows: compiler test may fail when using %:S
Bram Moolenaar <Bram@vim.org>
parents: 14260
diff changeset
18 let save_shellslash = &shellslash
0d7c87cad133 patch 8.1.1783: MS-Windows: compiler test may fail when using %:S
Bram Moolenaar <Bram@vim.org>
parents: 14260
diff changeset
19 set noshellslash
0d7c87cad133 patch 8.1.1783: MS-Windows: compiler test may fail when using %:S
Bram Moolenaar <Bram@vim.org>
parents: 14260
diff changeset
20
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 e Xfoo.pl
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 compiler perl
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 call assert_equal('perl', b:current_compiler)
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 call assert_fails('let g:current_compiler', 'E121:')
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 call setline(1, ['#!/usr/bin/perl -w', 'use strict;', 'my $foo=1'])
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 w!
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 call feedkeys(":make\<CR>\<CR>", 'tx')
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 call assert_fails('clist', 'E42:')
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call setline(1, ['#!/usr/bin/perl -w', 'use strict;', '$foo=1'])
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 w!
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call feedkeys(":make\<CR>\<CR>", 'tx')
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 let a=execute('clist')
18118
9b7c7754ba9d patch 8.1.2054: compiler test for Perl may fail
Bram Moolenaar <Bram@vim.org>
parents: 17572
diff changeset
35 call assert_match('\n \d\+ Xfoo.pl:3: Global symbol "$foo" '
9b7c7754ba9d patch 8.1.2054: compiler test for Perl may fail
Bram Moolenaar <Bram@vim.org>
parents: 17572
diff changeset
36 \ . 'requires explicit package name', a)
9b7c7754ba9d patch 8.1.2054: compiler test for Perl may fail
Bram Moolenaar <Bram@vim.org>
parents: 17572
diff changeset
37
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
17572
0d7c87cad133 patch 8.1.1783: MS-Windows: compiler test may fail when using %:S
Bram Moolenaar <Bram@vim.org>
parents: 14260
diff changeset
39 let &shellslash = save_shellslash
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call delete('Xfoo.pl')
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 bw!
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 endfunc
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43
22981
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
44 func GetCompilerNames()
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
45 return glob('$VIMRUNTIME/compiler/*.vim', 0, 1)
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
46 \ ->map({k, v -> substitute(v, '.*[\\/]\([a-zA-Z0-9_\-]*\).vim', '\1', '')})
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
47 endfunc
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
48
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 func Test_compiler_without_arg()
18273
fc68850c5233 patch 8.1.2131: MSVC tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18269
diff changeset
50 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g')
fc68850c5233 patch 8.1.2131: MSVC tests fail
Bram Moolenaar <Bram@vim.org>
parents: 18269
diff changeset
51 let a = split(execute('compiler'))
22981
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
52 let exp = GetCompilerNames()
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
53 call assert_match(runtime .. '/compiler/' .. exp[0] .. '.vim$', a[0])
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
54 call assert_match(runtime .. '/compiler/' .. exp[1] .. '.vim$', a[1])
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
55 call assert_match(runtime .. '/compiler/' .. exp[-1] .. '.vim$', a[-1])
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 endfunc
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
19348
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19289
diff changeset
58 " Test executing :compiler from the command line, not from a script
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19289
diff changeset
59 func Test_compiler_commandline()
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19289
diff changeset
60 call system(GetVimCommandClean() .. ' --not-a-term -c "compiler gcc" -c "call writefile([b:current_compiler], ''XcompilerOut'')" -c "quit"')
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19289
diff changeset
61 call assert_equal(0, v:shell_error)
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19289
diff changeset
62 call assert_equal(["gcc"], readfile('XcompilerOut'))
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19289
diff changeset
63
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19289
diff changeset
64 call delete('XcompilerOut')
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19289
diff changeset
65 endfunc
b6da81589f8c patch 8.2.0232: the :compiler command causes a crash
Bram Moolenaar <Bram@vim.org>
parents: 19289
diff changeset
66
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 func Test_compiler_completion()
22981
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
68 let clist = GetCompilerNames()->join(' ')
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 call feedkeys(":compiler \<C-A>\<C-B>\"\<CR>", 'tx')
22981
72e0ec552189 patch 8.2.2037: compiler test depends on list of compiler plugins
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
70 call assert_match('^"compiler ' .. clist .. '$', @:)
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx')
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 call assert_equal('"compiler pbx perl php pylint pyunit', @:)
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx')
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 call assert_equal('"compiler! pbx perl php pylint pyunit', @:)
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 endfunc
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 func Test_compiler_error()
19289
2f0f308c069c patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
80 let g:current_compiler = 'abc'
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 call assert_fails('compiler doesnotexist', 'E666:')
19289
2f0f308c069c patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
82 call assert_equal('abc', g:current_compiler)
2f0f308c069c patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
83 call assert_fails('compiler! doesnotexist', 'E666:')
2f0f308c069c patch 8.2.0203: :helptags and some other functionality not tested
Bram Moolenaar <Bram@vim.org>
parents: 18767
diff changeset
84 unlet! g:current_compiler
13970
939cfab265b9 patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21721
diff changeset
86
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 21721
diff changeset
87 " vim: shiftwidth=2 sts=2 expandtab