Skip to content

Commit dde6034

Browse files
committed
patch 8.0.1017: test for MS-Windows $HOME always passes
Problem: Test for MS-Windows $HOME always passes. Solution: Rename the test function. Make the test pass.
1 parent f3af54e commit dde6034

2 files changed

Lines changed: 40 additions & 41 deletions

File tree

src/testdir/test_windows_home.vim

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -38,76 +38,73 @@ func CheckHomeIsInSubprocessEnvironment(exp)
3838
endfunc
3939

4040
func CheckHome(exp, ...)
41-
"call assert_equal(a:exp, $HOME)
42-
"call assert_equal(a:exp, expand('~', ':p'))
41+
call assert_equal(a:exp, $HOME)
42+
call assert_equal(a:exp, expand('~', ':p'))
4343
if !a:0
4444
call CheckHomeIsMissingFromSubprocessEnvironment()
4545
else
46-
call CheckHomeIsInSubprocessEnvironment(a:exp)
46+
call CheckHomeIsInSubprocessEnvironment(a:1)
4747
endif
4848
endfunc
4949

50-
func TestWindowsHome()
50+
func Test_WindowsHome()
5151
command! -nargs=* SaveEnv call <SID>save_env(<f-args>)
5252
command! -nargs=* RestoreEnv call <SID>restore_env()
5353
command! -nargs=* UnletEnv call <SID>unlet_env(<f-args>)
54+
set noshellslash
5455

55-
SaveEnv $HOME $USERPROFILE $HOMEDRIVE $HOMEPATH
56+
let save_home = $HOME
57+
SaveEnv $USERPROFILE $HOMEDRIVE $HOMEPATH
5658
try
57-
RestoreEnv
58-
UnletEnv $HOME $USERPROFILE $HOMEPATH
59-
let $HOMEDRIVE = 'C:'
60-
call CheckHome('C:\')
61-
62-
RestoreEnv
63-
UnletEnv $HOME $USERPROFILE
59+
" Normal behavior: use $HOMEDRIVE and $HOMEPATH, ignore $USERPROFILE
60+
let $USERPROFILE = 'unused'
6461
let $HOMEDRIVE = 'C:'
6562
let $HOMEPATH = '\foobar'
63+
let $HOME = '' " Force recomputing "homedir"
6664
call CheckHome('C:\foobar')
6765

68-
RestoreEnv
69-
UnletEnv $HOME $HOMEDRIVE $HOMEPATH
70-
let $USERPROFILE = 'C:\foo'
71-
call CheckHome('C:\foo')
66+
" Same, but with $HOMEPATH not set
67+
UnletEnv $HOMEPATH
68+
let $HOME = '' " Force recomputing "homedir"
69+
call CheckHome('C:\')
7270

73-
RestoreEnv
74-
UnletEnv $HOME
71+
" Use $USERPROFILE if $HOMEPATH and $HOMEDRIVE are empty
72+
UnletEnv $HOMEDRIVE $HOMEPATH
7573
let $USERPROFILE = 'C:\foo'
76-
let $HOMEDRIVE = 'C:'
77-
let $HOMEPATH = '\baz'
74+
let $HOME = '' " Force recomputing "homedir"
7875
call CheckHome('C:\foo')
7976

80-
RestoreEnv
77+
" If $HOME is set the others don't matter
8178
let $HOME = 'C:\bar'
82-
let $USERPROFILE = 'C:\foo'
83-
let $HOMEDRIVE = 'C:'
84-
let $HOMEPATH = '\baz'
85-
call CheckHome('C:\bar', 1)
79+
let $USERPROFILE = 'unused'
80+
let $HOMEDRIVE = 'unused'
81+
let $HOMEPATH = 'unused'
82+
call CheckHome('C:\bar', 'C:\bar')
8683

87-
RestoreEnv
88-
let $HOME = '%USERPROFILE%\bar'
84+
" If $HOME contains %USERPROFILE% it is expanded
8985
let $USERPROFILE = 'C:\foo'
90-
let $HOMEDRIVE = 'C:'
91-
let $HOMEPATH = '\baz'
92-
call CheckHome('%USERPROFILE%\bar', 1)
86+
let $HOME = '%USERPROFILE%\bar'
87+
let $HOMEDRIVE = 'unused'
88+
let $HOMEPATH = 'unused'
89+
call CheckHome('C:\foo\bar', '%USERPROFILE%\bar')
9390

94-
RestoreEnv
95-
let $HOME = '%USERPROFILE'
91+
" Invalid $HOME is kept
9692
let $USERPROFILE = 'C:\foo'
97-
let $HOMEDRIVE = 'C:'
98-
let $HOMEPATH = '\baz'
99-
call CheckHome('%USERPROFILE', 1)
93+
let $HOME = '%USERPROFILE'
94+
let $HOMEDRIVE = 'unused'
95+
let $HOMEPATH = 'unused'
96+
call CheckHome('%USERPROFILE', '%USERPROFILE')
10097

101-
RestoreEnv
98+
" %USERPROFILE% not at start of $HOME is not expanded
99+
let $USERPROFILE = 'unused'
102100
let $HOME = 'C:\%USERPROFILE%'
103-
let $USERPROFILE = 'C:\foo'
104-
let $HOMEDRIVE = 'C:'
105-
let $HOMEPATH = '\baz'
106-
call CheckHome('C:\%USERPROFILE%', 1)
101+
let $HOMEDRIVE = 'unused'
102+
let $HOMEPATH = 'unused'
103+
call CheckHome('C:\%USERPROFILE%', 'C:\%USERPROFILE%')
107104

108105
if has('channel')
109106
RestoreEnv
110-
UnletEnv $HOME
107+
let $HOME = save_home
111108
let env = ''
112109
let job = job_start('cmd /c set', {'out_cb': {ch,x->[env,execute('let env=x')]}})
113110
sleep 1

src/version.c

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

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
1017,
772774
/**/
773775
1016,
774776
/**/

0 commit comments

Comments
 (0)