Skip to content

Commit 6995c0a

Browse files
committed
patch 8.0.1695: xxd test not run on MS-Windows
Problem: Xxd test not run on MS-Windows. Solution: Use xxd.exe if it exists.
1 parent b377457 commit 6995c0a

2 files changed

Lines changed: 23 additions & 10 deletions

File tree

‎src/testdir/test_xxd.vim‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
" Test for the xxd command
2-
if empty($XXD) || !executable($XXD)
2+
if empty($XXD) && executable('..\xxd\xxd.exe')
3+
let s:xxd_cmd = '..\xxd\xxd.exe'
4+
elseif empty($XXD) || !executable($XXD)
35
finish
6+
else
7+
let s:xxd_cmd = $XXD
48
endif
59

610
func! PrepareBuffer(lines)
@@ -15,11 +19,12 @@ endfunc
1519

1620
func! Test_xxd()
1721
call PrepareBuffer(range(1,30))
22+
set ff=unix
1823
w XXDfile
1924

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

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

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

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

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

6873
" Test 7: Print C include
6974
let s:test += 1
7075
call writefile(['TESTabcd09'], 'XXDfile')
7176
%d
72-
0r! $XXD -i XXDfile
77+
exe '0r! ' . s:xxd_cmd . ' -i XXDfile'
7378
$d
7479
let expected = ['unsigned char XXDfile[] = {',
7580
\ ' 0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a', '};',
@@ -80,7 +85,7 @@ func! Test_xxd()
8085
let s:test += 1
8186
call writefile(['TESTabcd09'], 'XXDfile')
8287
%d
83-
0r! $XXD -i -C XXDfile
88+
exe '0r! ' . s:xxd_cmd . ' -i -C XXDfile'
8489
$d
8590
let expected = ['unsigned char XXDFILE[] = {',
8691
\ ' 0x54, 0x45, 0x53, 0x54, 0x61, 0x62, 0x63, 0x64, 0x30, 0x39, 0x0a', '};',
@@ -91,7 +96,13 @@ func! Test_xxd()
9196
let s:test += 1
9297
call delete('XXDfile')
9398
bwipe! XXDfile
94-
call system('echo "010000: 41"|'.$XXD.' -r -s -0x10000 > XXDfile')
99+
if has('unix')
100+
call system('echo "010000: 41"|' . s:xxd_cmd . ' -r -s -0x10000 > XXDfile')
101+
else
102+
call writefile(['010000: 41'], 'Xinput')
103+
silent exe '!' . s:xxd_cmd . ' -r -s -0x10000 < Xinput > XXDfile'
104+
call delete('Xinput')
105+
endif
95106
call PrepareBuffer(readfile('XXDfile')[0])
96107
call assert_equal('A', getline(1), s:Mess(s:test))
97108
call delete('XXDfile')

‎src/version.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ static char *(features[]) =
762762

763763
static int included_patches[] =
764764
{ /* Add new patch number below this line */
765+
/**/
766+
1695,
765767
/**/
766768
1694,
767769
/**/

0 commit comments

Comments
 (0)