Skip to content

Commit

Permalink
patch 9.0.1656: syntax test fails when detected shell type differs
Browse files Browse the repository at this point in the history
Problem:    Syntax test fails when detected shell type differs.
Solution:   Avoid using "/bin/sh", it depends on the system.  Add a check that
            the shell type detection is correct.
  • Loading branch information
brammool committed Jun 23, 2023
1 parent 2f43ec9 commit 7d0dbd0
Show file tree
Hide file tree
Showing 17 changed files with 58 additions and 24 deletions.
4 changes: 2 additions & 2 deletions runtime/syntax/testdir/dumps/sh_01_00.dump
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
>#+0#0000e05#ffffff0|!| |/|b|i|n|/|s|h| +0#0000000&@64
>#+0#0000e05#ffffff0|!| |/|b|i|n|/|d|a|s|h| +0#0000000&@62
|e+0#af5f00255&|x|p|o|r|t| +0#0000000&|`+0#e000e06&|e+0#af5f00255&|c|h|o| +0#e000002&|'+0#af5f00255&|A+0#e000002&|=|B|'+0#af5f00255&|`+0#e000e06&| +0#0000000&@55
|p+0#af5f00255&|r|i|n|t|e|n|v| +0#0000000&|A| @64
|e+0#af5f00255&|c|h|o| +0#e000002&|a| |`+0#e000e06&|#+0#0000e05&|f|o@1|`+0#e000e06&| +0#0000000&|b| @59
Expand All @@ -17,4 +17,4 @@
|~| @73
|~| @73
|~| @73
|"+0#0000000&|i|n|p|u|t|/|s|h|_|0|1|.|s|h|"| |4|L|,| |5|8|B| @32|1|,|1| @10|A|l@1|
|i+0#0000000&|s|_|d|a|s|h|:| |1|,| |i|s|_|p|o|s|i|x|:| |1|,| |i|s|_|s|h|:| |1|,| @22|1|,|1| @10|A|l@1|
4 changes: 2 additions & 2 deletions runtime/syntax/testdir/dumps/sh_01_99.dump
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
|#+0#0000e05#ffffff0|!| |/|b|i|n|/|s|h| +0#0000000&@64
|#+0#0000e05#ffffff0|!| |/|b|i|n|/|d|a|s|h| +0#0000000&@62
|e+0#af5f00255&|x|p|o|r|t| +0#0000000&|`+0#e000e06&|e+0#af5f00255&|c|h|o| +0#e000002&|'+0#af5f00255&|A+0#e000002&|=|B|'+0#af5f00255&|`+0#e000e06&| +0#0000000&@55
|p+0#af5f00255&|r|i|n|t|e|n|v| +0#0000000&|A| @64
>e+0#af5f00255&|c|h|o| +0#e000002&|a| |`+0#e000e06&|#+0#0000e05&|f|o@1|`+0#e000e06&| +0#0000000&|b| @59
Expand All @@ -17,4 +17,4 @@
|~| @73
|~| @73
|~| @73
|"+0#0000000&|i|n|p|u|t|/|s|h|_|0|1|.|s|h|"| |4|L|,| |5|8|B| @32|4|,|1| @10|A|l@1|
|:+0#0000000&|r|e|d|r|a|w| @49|4|,|1| @10|A|l@1|
2 changes: 1 addition & 1 deletion runtime/syntax/testdir/dumps/sh_02_00.dump
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
|#+0#0000e05&| |J|u|l| |2|6|,| |2|0|1|8|:| |w|h|y| |i|s|n|'|t| |`|.@1|`| |b|e|i|n|g| |t|e|r|m|i|n|a|t|e|d| |p|r|o|p|e|r|l|y|?| +0#0000000&@17
|#+0#0000e05&| |c|o|m@1|e|n|t| +0#0000000&@65
|c+0#af5f00255&|a|s|e| +0#0000000&|"+0#af5f00255&|$+0#e000e06&|a@2|"+0#af5f00255&| +0#0000000&|i+0#af5f00255&|n| +0#0000000&@60
|"|i|n|p|u|t|/|s|h|_|0|2|.|s|h|"| |3|0|L|,| |4|9|7|B| @30|1|,|1| @10|T|o|p|
|i|s|_|k|o|r|n|s|h|e|l@1|:| |1|,| @40|1|,|1| @10|T|o|p|
2 changes: 1 addition & 1 deletion runtime/syntax/testdir/dumps/sh_03_00.dump
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
|a|s| |w|e|l@1| |a|s| |b|a|s|h| +0#0000000&@59
|V+0#00e0e07&|a|r|i|a|b|l|e|=+0#0000000&|$+0#e000e06&|{|V|a|r|i|a|b|l|e|B|:+0#af5f00255&|-|$+0#e000e06&|{|V|a|r|i|a|b|l|e|C|:+0#af5f00255&|-|e+0#0000000&|n|g|}+0#e000e06&@1| +0#0000000&@7|#+0#0000e05&| |:|-| |i|s| |k|s|h| |a|n|d| |b|a|s|h| +0#0000000&@6
@75
|"|i|n|p|u|t|/|s|h|_|0|3|.|s|h|"| |3@1|L|,| |9|7|1|B| @30|1|,|1| @10|T|o|p|
|i|s|_|k|o|r|n|s|h|e|l@1|:| |1|,| @40|1|,|1| @10|T|o|p|
4 changes: 2 additions & 2 deletions runtime/syntax/testdir/dumps/sh_04_00.dump
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
>#+0#0000e05#ffffff0|!|/|b|i|n|/|s|h| +0#0000000&@65
>#+0#0000e05#ffffff0|!|/|b|i|n|/|d|a|s|h| +0#0000000&@63
|#+0#0000e05&| |s|h|4| +0#0000000&@69
|V+0#00e0e07&|a|r|i|a|b|l|e|=+0#0000000&|$+0#e000e06&|{|V|a|r|i|a|b|l|e|B|:+0#af5f00255&|-|{+0#0000000&|V|a|r|i|a|b|l|e|C|}|}+0#e000e06&| +0#0000000&@40
|V+0#00e0e07&|a|r|i|a|b|l|e|=+0#0000000&|$+0#e000e06&|{|V|a|r|i|a|b|l|e|B|:+0#af5f00255&|-|$+0#e000e06&|{|V|a|r|i|a|b|l|e|C|:+0#af5f00255&|-|{+0#0000000&|V|a|r|3|:|=|e|n|g|}|}+0#e000e06&@1| +0#0000000&@26
Expand All @@ -17,4 +17,4 @@
|:+0#0000e05&| +0#0000000&|$+0#e000e06&|{|V|a|r|i|a|b|l|e|B|:+0#af5f00255&|-|$+0#e000e06&|{|V|a|r|i|a|b|l|e|C|:+0#af5f00255&|-|{+0#0000000&|V|a|r|3|:|=|e|n|g|}|}+0#e000e06&@1| +0#0000000&@33
|:+0#0000e05&| +0#0000000&|$+0#e000e06&|{|V|a|r|i|a|b|l|e|B|:+0#af5f00255&|=|$+0#e000e06&|{|V|a|r|i|a|b|l|e|C|:+0#af5f00255&|=|{+0#0000000&|V|a|r|3|:|=|$+0#e000e06&|{|V|a|r|4|:+0#af5f00255&|-|e+0#0000000&|n|g|}+0#e000e06&|}+0#0000000&|}+0#e000e06&@1| +0#0000000&@24
@75
|"|i|n|p|u|t|/|s|h|_|0|4|.|s|h|"| |2|7|L|,| |9|4|0|B| @30|1|,|1| @10|T|o|p|
|i|s|_|d|a|s|h|:| |1|,| |i|s|_|p|o|s|i|x|:| |1|,| |i|s|_|s|h|:| |1|,| @22|1|,|1| @10|T|o|p|
2 changes: 1 addition & 1 deletion runtime/syntax/testdir/dumps/sh_05_00.dump
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
|V+0#00e0e07&|a|r|i|a|b|l|e|1|=+0#0000000&|$+0#e000e06&|H|O|M|E| +0#0000000&@59
|V+0#00e0e07&|a|r|i|a|b|l|e|2|=+0#0000000&|'+0#af5f00255&|$+0#e000002&|H|O|M|E|'+0#af5f00255&| +0#0000000&@57
|V+0#00e0e07&|a|r|i|a|b|l|e|3|=+0#0000000&|"+0#af5f00255&|$+0#e000e06&|H|O|M|E|"+0#af5f00255&| +0#0000000&@57
|"|i|n|p|u|t|/|s|h|_|0|5|.|s|h|"| |3|7|3|L|,| |1|2|9|5|4|B| @27|1|,|1| @10|T|o|p|
|i|s|_|d|a|s|h|:| |1|,| |i|s|_|p|o|s|i|x|:| |1|,| |i|s|_|s|h|:| |1|,| @22|1|,|1| @10|T|o|p|
2 changes: 1 addition & 1 deletion runtime/syntax/testdir/dumps/sh_06_00.dump
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
|V+0#00e0e07&|a|r|i|a|b|l|e|N|a|m|e|=+0#0000000&|"+0#af5f00255&|$+0#e000e06&|{|B|a|s|i|c|C|o|n|f|i|g|N|a|m|e|}|_+0#e000002&|*|"+0#af5f00255&| +0#0000000&@39
@75
|#+0#0000e05&| |E|c|h|o| |s|o|m|e| |k|s|h| |s|p|e|c|i|a|l| |v|a|r|i|a|b|l|e|s| +0#0000000&@41
|"|i|n|p|u|t|/|s|h|_|0|6|.|s|h|"| |7|1|L|,| |1|6|7@1|B| @29|1|,|1| @10|T|o|p|
|i|s|_|k|o|r|n|s|h|e|l@1|:| |1|,| @40|1|,|1| @10|T|o|p|
4 changes: 2 additions & 2 deletions runtime/syntax/testdir/dumps/sh_07_00.dump
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
>#+0#0000e05#ffffff0|!|/|b|i|n|/|s|h| +0#0000000&@65
>#+0#0000e05#ffffff0|!|/|b|i|n|/|d|a|s|h| +0#0000000&@63
|#+0#0000e05&| |T|e|s|t| |f|i|l|e| |t|o| |t|e|s|t| |'|f|o|r| |d|o| |d|o|n|e|'| |l|o@1|p|s|.| +0#0000000&@34
|#+0#0000e05&| |Y|o|u| |c|a|n| |s|t|a|r|t| |t|h|i|s| |s|c|r|i|p|t| |l|i|k|e|:| |$|0| |{|-|n|e| |-|g|t| |-|l|e| |.@2|}| |(|a|l@1| |n|u|m|e|r|i|c| |o|p|e|r|a|t|o
|r|s| | +0#0000000&@71
Expand All @@ -17,4 +17,4 @@
|F+0#00e0e07&|u|n|c|t|i|o|n|1| |(|)| |{| +0#0000000&@60
@75
|e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|F+0#e000002&|u|n|c|t|i|o|n|1|:| |f|o|r| |l|o@1|p| |i|n|s|i|d|e| |a| |f|u|n|c|t|i|o|n|:|\+0#e000e06&|t|\|c|"+0#af5f00255&| +0#0000000&@25
|"|i|n|p|u|t|/|s|h|_|0|7|.|s|h|"| |9|3|L|,| |2|3|0|3|B| @29|1|,|1| @10|T|o|p|
|i|s|_|d|a|s|h|:| |1|,| |i|s|_|p|o|s|i|x|:| |1|,| |i|s|_|s|h|:| |1|,| @22|1|,|1| @10|T|o|p|
2 changes: 1 addition & 1 deletion runtime/syntax/testdir/dumps/sh_08_00.dump
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
|#+0#0000e05&| |C|a|s|e| |1|b|.| |V|a|r|i|a|b|l|e| |a|n|d| |C|o|n|s|t|a|n|t| +0#0000000&@42
|[+0#af5f00255&| +0#0000000&|-+0#af5f00255&|t| +0#0000000&|0+0#e000002&| +0#0000000&|]+0#af5f00255&| +0#0000000&|&@1| |e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|\+0#e000e06&|n|`|d|a|t|e|`|"+0#af5f00255&| +0#e000002&|&+0#0000000&@1| |u+0#af5f00255&|n|s|e|t| +0#00e0e07&|V|a|r|i|a|b|l|e|A| +0#0000000&@28
|V+0#00e0e07&|a|r|i|a|b|l|e|1|=+0#0000000&|$+0#e000e06&|{|V|a|r|i|a|b|l|e|A|:+0#af5f00255&|-|$+0#e000e06&|H|O|M|E| +0#0000000&|T|h|i|s| |i|s| |a| |T|e|x|t|}+0#e000e06&| +0#0000000&@30
|"|i|n|p|u|t|/|s|h|_|0|8|.|s|h|"| |8|2|L|,| |2|9@1|3|B| @29|1|,|1| @10|T|o|p|
|i|s|_|k|o|r|n|s|h|e|l@1|:| |1|,| @40|1|,|1| @10|T|o|p|
4 changes: 2 additions & 2 deletions runtime/syntax/testdir/dumps/sh_09_00.dump
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
>#+0#0000e05#ffffff0|!|/|b|i|n|/|s|h| +0#0000000&@65
>#+0#0000e05#ffffff0|!|/|b|i|n|/|d|a|s|h| +0#0000000&@63
|#+0#0000e05&| |T|e|s|t| |f|i|l|e| |f|o|r| |v|i|m| |t|h|e| |c|h|e|c|k| |(|)| |s|u|b|s|h|e|l@1|s| +0#0000000&@32
|(+0#e000e06&| |c+0#af5f00255&|d| +0#e000e06&|;+0#af5f00255&| +0#e000e06&|$|p|w|d| |)| +0#0000000&||| |w|c| |-+0#e000e06&|c| +0#0000000&@53
|(+0#e000e06&| |c+0#af5f00255&|d| +0#e000e06&|$|1| |;+0#af5f00255&| +0#e000e06&|$|p|w|d| |)| +0#0000000&||| |w|c| |-+0#e000e06&|c| +0#0000000&@50
Expand All @@ -17,4 +17,4 @@
|(+0#e000e06&| |c+0#af5f00255&|d| +0#e000e06&|$|{|H|O|M|E|}| |)| +0#0000000&||| |w|c| |-+0#e000e06&|c| +0#0000000&@52
|(|(+0#e000e06&|n+0#00e0e07&|=+0#0000000&|1+0#e000002&|+|2|)+0#e000e06&|)+0#ffffff16#ff404010| +0#0000000#ffffff0@65
|l+0#af5f00255&|e|t| +0#0000000&|n+0#00e0e07&|=+0#0000000&|1+0#e000002&|++0#0000000&|2+0#e000002&| +0#0000000&@65
|"|i|n|p|u|t|/|s|h|_|0|9|.|s|h|"| |1|9|L|,| |4|8|3|B| @30|1|,|1| @10|A|l@1|
|i|s|_|d|a|s|h|:| |1|,| |i|s|_|p|o|s|i|x|:| |1|,| |i|s|_|s|h|:| |1|,| @22|1|,|1| @10|A|l@1|
4 changes: 2 additions & 2 deletions runtime/syntax/testdir/dumps/sh_09_99.dump
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
|#+0#0000e05#ffffff0|!|/|b|i|n|/|s|h| +0#0000000&@65
|#+0#0000e05#ffffff0|!|/|b|i|n|/|d|a|s|h| +0#0000000&@63
|#+0#0000e05&| |T|e|s|t| |f|i|l|e| |f|o|r| |v|i|m| |t|h|e| |c|h|e|c|k| |(|)| |s|u|b|s|h|e|l@1|s| +0#0000000&@32
|(+0#e000e06&| |c+0#af5f00255&|d| +0#e000e06&|;+0#af5f00255&| +0#e000e06&|$|p|w|d| |)| +0#0000000&||| |w|c| |-+0#e000e06&|c| +0#0000000&@53
|(+0#e000e06&| |c+0#af5f00255&|d| +0#e000e06&|$|1| |;+0#af5f00255&| +0#e000e06&|$|p|w|d| |)| +0#0000000&||| |w|c| |-+0#e000e06&|c| +0#0000000&@50
Expand All @@ -17,4 +17,4 @@
|(+0#e000e06&| |c+0#af5f00255&|d| +0#e000e06&|$|{|H|O|M|E|}| |)| +0#0000000&||| |w|c| |-+0#e000e06&|c| +0#0000000&@52
|(|(+0#e000e06&|n+0#00e0e07&|=+0#0000000&|1+0#e000002&|+|2|)+0#e000e06&|)+0#ffffff16#ff404010| +0#0000000#ffffff0@65
>l+0#af5f00255&|e|t| +0#0000000&|n+0#00e0e07&|=+0#0000000&|1+0#e000002&|++0#0000000&|2+0#e000002&| +0#0000000&@65
|"|i|n|p|u|t|/|s|h|_|0|9|.|s|h|"| |1|9|L|,| |4|8|3|B| @30|1|9|,|1| @9|A|l@1|
|:|r|e|d|r|a|w| @49|1|9|,|1| @9|A|l@1|
2 changes: 1 addition & 1 deletion runtime/syntax/testdir/input/sh_01.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/sh
#! /bin/dash
export `echo 'A=B'`
printenv A
echo a `#foo` b
2 changes: 1 addition & 1 deletion runtime/syntax/testdir/input/sh_04.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/dash
# sh4
Variable=${VariableB:-{VariableC}}
Variable=${VariableB:-${VariableC:-{Var3:=eng}}}
Expand Down
2 changes: 1 addition & 1 deletion runtime/syntax/testdir/input/sh_07.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/dash
# Test file to test 'for do done' loops.
# You can start this script like: $0 {-ne -gt -le ...} (all numeric operators
# are allowed!
Expand Down
2 changes: 1 addition & 1 deletion runtime/syntax/testdir/input/sh_09.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/dash
# Test file for vim the check () subshells
( cd ; $pwd ) | wc -c
( cd $1 ; $pwd ) | wc -c
Expand Down
38 changes: 35 additions & 3 deletions runtime/syntax/testdir/runtest.vim
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func HandleSwapExists()
endif
endfunc


let ok_count = 0
let failed_tests = []
let skipped_count = 0
Expand Down Expand Up @@ -115,6 +114,28 @@ for fname in glob('input/*.*', 1, 1)

let lines =<< trim END
syntax on

" extra info for shell variables
func ShellInfo()
let msg = ''
for [key, val] in items(b:)
if key =~ '^is_'
let msg ..= key .. ': ' .. val .. ', '
endif
endfor
if msg != ''
echomsg msg
endif
endfunc

au! SwapExists * call HandleSwapExists()
func HandleSwapExists()
" Ignore finding a swap file for the test input, the user might be
" editing it and that's OK.
if expand('<afile>') =~ 'input[/\\].*\..*'
let v:swapchoice = 'e'
endif
endfunc
END
call writefile(lines, 'Xtestscript')

Expand All @@ -127,13 +148,24 @@ for fname in glob('input/*.*', 1, 1)
" for the terminal window.
redraw

let buf = RunVimInTerminal('-S Xtestscript ' .. fname, {})
let buf = RunVimInTerminal('-S Xtestscript', {})
" edit the file only after catching the SwapExists event
call term_sendkeys(buf, ":edit " .. fname .. "\<CR>")

if filetype == 'sh'
call term_sendkeys(buf, ":call ShellInfo()\<CR>")
endif

" Screendump at the start of the file: failed/filetype_00.dump
" Screendump at the start of the file: failed/root_00.dump
let root_00 = root .. '_00'
call ch_log('First screendump for ' .. fname .. ': failed/' .. root_00 .. '.dump')
let fail = VerifyScreenDump(buf, root_00, {})

" clear the shell info if there are not enough lines to cause a scroll
if filetype == 'sh' && linecount <= 19
call term_sendkeys(buf, ":redraw\<CR>")
endif

" Make a Screendump every 18 lines of the file: failed/root_NN.dump
let topline = 1
let nr = 1
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1656,
/**/
1655,
/**/
Expand Down

0 comments on commit 7d0dbd0

Please sign in to comment.