blob: 0cbf4bf6d6ad5556c20ff18c3419abeced890e32 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001Test for shortpathname ':8' extension.
2Only for use on Win32 systems!
3
4STARTTEST
5:so small.vim
6:fun! TestIt(file, bits, expected)
7 let res=fnamemodify(a:file,a:bits)
8 if a:expected == ''
9 echo "'".a:file."'->(".a:bits.")->'".res."'"
10 else
11 if substitute(res,'/','\\', 'g') != substitute( a:expected, '/','\\', 'g')
12 echo "FAILED: '".a:file."'->(".a:bits.")->'".res."'"
13 echo "Expected: '".a:expected."'"
14 else
15 echo "OK"
16 endif
17 endif
18endfun
19:fun! MakeDir( dirname )
20 "exe '!mkdir '.substitute(a:dirname,'/','\\','g')
21 call system('mkdir '.substitute(a:dirname,'/','\\','g'))
22endfun
23:fun! RMDir( dirname)
24 "exe '!rmdir '.substitute(a:dirname,'/','\\','g')
25 call system('rmdir '.substitute(a:dirname,'/','\\','g'))
26endfun
27:fun! MakeFile( filename)
28 "exe '!copy nul '.substitute(a:filename,'/','\\','g')
29 call system('copy nul '.substitute(a:filename,'/','\\','g'))
30endfun
31:fun! TestColonEight()
32 redir! >test.out
33 " This could change for CygWin to //cygdrive/c
34 let dir1='c:/x.x.y'
35 if filereadable(dir1) || isdirectory(dir1)
Bram Moolenaard73895e2013-06-19 21:17:31 +020036 echo "FATAL: '".dir1."' exists, cannot run test"
Bram Moolenaar071d4272004-06-13 20:20:40 +000037 return
38 endif
39 let file1=dir1.'/zz.y.txt'
40 let nofile1=dir1.'/z.y.txt'
41 let dir2=dir1.'/VimIsTheGreatestSinceSlicedBread'
42 let file2=dir2.'/z.txt'
43 let nofile2=dir2.'/zz.txt'
Bram Moolenaard73895e2013-06-19 21:17:31 +020044 call MakeDir( dir1 )
45 let resdir1 = substitute(fnamemodify(dir1, ':p:8'), '\\$', '', '')
46 if resdir1 !~ '\V\^c:/XX\x\x\x\x~1.Y\$'
47 echo "FATAL: unexpected short name: " . resdir1
48 echo "INFO: please report your OS to vim-dev"
49 return
50 endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000051 let resfile1=resdir1.'/ZZY~1.TXT'
52 let resnofile1=resdir1.'/z.y.txt'
53 let resdir2=resdir1.'/VIMIST~1'
54 let resfile2=resdir2.'/z.txt'
55 let resnofile2=resdir2.'/zz.txt'
Bram Moolenaar071d4272004-06-13 20:20:40 +000056 call MakeDir( dir2 )
57 call MakeFile( file1 )
58 call MakeFile( file2 )
59 call TestIt(file1, ':p:8', resfile1)
60 call TestIt(nofile1, ':p:8', resnofile1)
61 call TestIt(file2, ':p:8', resfile2)
62 call TestIt(nofile2, ':p:8', resnofile2)
63 call TestIt(nofile2, ':p:8:h', fnamemodify(resnofile2,':h'))
64 exe 'cd '.dir1
65 call TestIt(file1, ':.:8', strpart(resfile1,strlen(resdir1)+1))
66 call TestIt(nofile1, ':.:8', strpart(resnofile1,strlen(resdir1)+1))
67 call TestIt(file2, ':.:8', strpart(resfile2,strlen(resdir1)+1))
68 call TestIt(nofile2, ':.:8', strpart(resnofile2,strlen(resdir1)+1))
69 let $HOME=dir1
70 call TestIt(file1, ':~:8', '~'.strpart(resfile1,strlen(resdir1)))
71 call TestIt(nofile1, ':~:8', '~'.strpart(resnofile1,strlen(resdir1)))
72 call TestIt(file2, ':~:8', '~'.strpart(resfile2,strlen(resdir1)))
73 call TestIt(nofile2, ':~:8', '~'.strpart(resnofile2,strlen(resdir1)))
74 cd c:/
75 call delete( file2 )
76 call delete( file1 )
77 call RMDir( dir2 )
78 call RMDir( dir1 )
79 echo
80 redir END
81endfun
82:let dir = getcwd()
83:call TestColonEight()
84:exe "cd " . dir
85:edit! test.out
86:set ff=dos
87:w
88:qa!
89ENDTEST
90