Mercurial > vim
annotate src/testdir/test_compiler.vim @ 18412:6208e5c2eee7 v8.1.2200
patch 8.1.2200: crash when memory allocation fails
Commit: https://github.com/vim/vim/commit/1cac70953d3c012453ea85b1308a8b1f94359c26
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 22 21:54:31 2019 +0200
patch 8.1.2200: crash when memory allocation fails
Problem: Crash when memory allocation fails.
Solution: Check for NULL curwin and curbuf. (Christian Brabandt,
closes #4839)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 22 Oct 2019 22:00:05 +0200 |
parents | fc68850c5233 |
children | 068337e86133 |
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 |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 func Test_compiler() |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 if !executable('perl') |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 return |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 endif |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
14260
9ff35e144467
patch 8.1.0146: when $LANG is set the compiler test may fail
Christian Brabandt <cb@256bit.org>
parents:
13974
diff
changeset
|
8 " $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
|
9 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
|
10 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
|
11 endif |
9ff35e144467
patch 8.1.0146: when $LANG is set the compiler test may fail
Christian Brabandt <cb@256bit.org>
parents:
13974
diff
changeset
|
12 |
17572
0d7c87cad133
patch 8.1.1783: MS-Windows: compiler test may fail when using %:S
Bram Moolenaar <Bram@vim.org>
parents:
14260
diff
changeset
|
13 " %: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
|
14 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
|
15 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
|
16 |
13970
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 e Xfoo.pl |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 compiler perl |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 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
|
20 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
|
21 |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 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
|
23 w! |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 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
|
25 call assert_fails('clist', 'E42:') |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 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
|
28 w! |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 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
|
30 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
|
31 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
|
32 \ . '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
|
33 |
13970
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 |
17572
0d7c87cad133
patch 8.1.1783: MS-Windows: compiler test may fail when using %:S
Bram Moolenaar <Bram@vim.org>
parents:
14260
diff
changeset
|
35 let &shellslash = save_shellslash |
13970
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 call delete('Xfoo.pl') |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 bw! |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 endfunc |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 func Test_compiler_without_arg() |
18273
fc68850c5233
patch 8.1.2131: MSVC tests fail
Bram Moolenaar <Bram@vim.org>
parents:
18269
diff
changeset
|
41 let runtime = substitute($VIMRUNTIME, '\\', '/', 'g') |
fc68850c5233
patch 8.1.2131: MSVC tests fail
Bram Moolenaar <Bram@vim.org>
parents:
18269
diff
changeset
|
42 let a = split(execute('compiler')) |
fc68850c5233
patch 8.1.2131: MSVC tests fail
Bram Moolenaar <Bram@vim.org>
parents:
18269
diff
changeset
|
43 call assert_match(runtime .. '/compiler/ant.vim$', a[0]) |
fc68850c5233
patch 8.1.2131: MSVC tests fail
Bram Moolenaar <Bram@vim.org>
parents:
18269
diff
changeset
|
44 call assert_match(runtime .. '/compiler/bcc.vim$', a[1]) |
fc68850c5233
patch 8.1.2131: MSVC tests fail
Bram Moolenaar <Bram@vim.org>
parents:
18269
diff
changeset
|
45 call assert_match(runtime .. '/compiler/xmlwf.vim$', a[-1]) |
13970
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 endfunc |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 func Test_compiler_completion() |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 call feedkeys(":compiler \<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
|
50 call assert_match('^"compiler ant bcc .* xmlwf$', @:) |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 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
|
53 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
|
54 |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 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
|
56 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
|
57 endfunc |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 func Test_compiler_error() |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 call assert_fails('compiler doesnotexist', 'E666:') |
939cfab265b9
patch 8.1.0003: the :compiler command is not tested
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 endfunc |