Skip to content

Commit

Permalink
patch 8.0.1695: xxd test not run on MS-Windows
Browse files Browse the repository at this point in the history
Problem:    Xxd test not run on MS-Windows.
Solution:   Use xxd.exe if it exists.
  • Loading branch information
brammool committed Apr 10, 2018
1 parent b377457 commit 6995c0a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/testdir/test_xxd.vim
@@ -1,6 +1,10 @@
" Test for the xxd command " Test for the xxd command
if empty($XXD) || !executable($XXD) if empty($XXD) && executable('..\xxd\xxd.exe')
let s:xxd_cmd = '..\xxd\xxd.exe'
elseif empty($XXD) || !executable($XXD)
finish finish
else
let s:xxd_cmd = $XXD
endif endif


func! PrepareBuffer(lines) func! PrepareBuffer(lines)
Expand All @@ -15,11 +19,12 @@ endfunc


func! Test_xxd() func! Test_xxd()
call PrepareBuffer(range(1,30)) call PrepareBuffer(range(1,30))
set ff=unix
w XXDfile w XXDfile


" Test 1: simple, filter the result through xxd " Test 1: simple, filter the result through xxd
let s:test = 1 let s:test = 1
%!$XXD % exe '%!' . s:xxd_cmd . ' %'
let expected = [ let expected = [
\ '00000000: 310a 320a 330a 340a 350a 360a 370a 380a 1.2.3.4.5.6.7.8.', \ '00000000: 310a 320a 330a 340a 350a 360a 370a 380a 1.2.3.4.5.6.7.8.',
\ '00000010: 390a 3130 0a31 310a 3132 0a31 330a 3134 9.10.11.12.13.14', \ '00000010: 390a 3130 0a31 310a 3132 0a31 330a 3134 9.10.11.12.13.14',
Expand All @@ -31,23 +36,23 @@ func! Test_xxd()


" Test 2: reverse the result " Test 2: reverse the result
let s:test += 1 let s:test += 1
%!$XXD -r exe '%!' . s:xxd_cmd . ' -r'
call assert_equal(map(range(1,30), {v,c -> string(c)}), getline(1,'$'), s:Mess(s:test)) call assert_equal(map(range(1,30), {v,c -> string(c)}), getline(1,'$'), s:Mess(s:test))


" Test 3: Skip the first 30 bytes " Test 3: Skip the first 30 bytes
let s:test += 1 let s:test += 1
%!$XXD -s 0x30 % exe '%!' . s:xxd_cmd . ' -s 0x30 %'
call assert_equal(expected[3:], getline(1,'$'), s:Mess(s:test)) call assert_equal(expected[3:], getline(1,'$'), s:Mess(s:test))


" Test 4: Skip the first 30 bytes " Test 4: Skip the first 30 bytes
let s:test += 1 let s:test += 1
%!$XXD -s -0x31 % exe '%!' . s:xxd_cmd . ' -s -0x31 %'
call assert_equal(expected[2:], getline(1,'$'), s:Mess(s:test)) call assert_equal(expected[2:], getline(1,'$'), s:Mess(s:test))


" Test 5: Print 120 bytes as continuous hexdump with 20 octets per line " Test 5: Print 120 bytes as continuous hexdump with 20 octets per line
let s:test += 1 let s:test += 1
%d %d
0r! $XXD -l 120 -ps -c 20 ../../runtime/doc/xxd.1 exe '0r! ' . s:xxd_cmd . ' -l 120 -ps -c 20 ../../runtime/doc/xxd.1'
$d $d
let expected = [ let expected = [
\ '2e54482058584420312022417567757374203139', \ '2e54482058584420312022417567757374203139',
Expand All @@ -61,15 +66,15 @@ func! Test_xxd()
" Test 6: Print the date from xxd.1 " Test 6: Print the date from xxd.1
let s:test += 1 let s:test += 1
%d %d
0r! $XXD -s 0x36 -l 13 -c 13 ../../runtime/doc/xxd.1 exe '0r! ' . s:xxd_cmd . ' -s 0x36 -l 13 -c 13 ../../runtime/doc/xxd.1'
$d $d
call assert_equal('00000036: 3231 7374 204d 6179 2031 3939 36 21st May 1996', getline(1), s:Mess(s:test)) call assert_equal('00000036: 3231 7374 204d 6179 2031 3939 36 21st May 1996', getline(1), s:Mess(s:test))


" Test 7: Print C include " Test 7: Print C include
let s:test += 1 let s:test += 1
call writefile(['TESTabcd09'], 'XXDfile') call writefile(['TESTabcd09'], 'XXDfile')
%d %d
0r! $XXD -i XXDfile exe '0r! ' . s:xxd_cmd . ' -i XXDfile'
$d $d
let expected = ['unsigned char XXDfile[] = {', let expected = ['unsigned char XXDfile[] = {',
\ ' 0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a', '};', \ ' 0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a', '};',
Expand All @@ -80,7 +85,7 @@ func! Test_xxd()
let s:test += 1 let s:test += 1
call writefile(['TESTabcd09'], 'XXDfile') call writefile(['TESTabcd09'], 'XXDfile')
%d %d
0r! $XXD -i -C XXDfile exe '0r! ' . s:xxd_cmd . ' -i -C XXDfile'
$d $d
let expected = ['unsigned char XXDFILE[] = {', let expected = ['unsigned char XXDFILE[] = {',
\ ' 0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a', '};', \ ' 0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a', '};',
Expand All @@ -91,7 +96,13 @@ func! Test_xxd()
let s:test += 1 let s:test += 1
call delete('XXDfile') call delete('XXDfile')
bwipe! XXDfile bwipe! XXDfile
call system('echo "010000: 41"|'.$XXD.' -r -s -0x10000 > XXDfile') if has('unix')
call system('echo "010000: 41"|' . s:xxd_cmd . ' -r -s -0x10000 > XXDfile')
else
call writefile(['010000: 41'], 'Xinput')
silent exe '!' . s:xxd_cmd . ' -r -s -0x10000 < Xinput > XXDfile'
call delete('Xinput')
endif
call PrepareBuffer(readfile('XXDfile')[0]) call PrepareBuffer(readfile('XXDfile')[0])
call assert_equal('A', getline(1), s:Mess(s:test)) call assert_equal('A', getline(1), s:Mess(s:test))
call delete('XXDfile') call delete('XXDfile')
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -762,6 +762,8 @@ static char *(features[]) =


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

0 comments on commit 6995c0a

Please sign in to comment.