changeset 12275:67bc88591ede v8.0.1017

patch 8.0.1017: test for MS-Windows $HOME always passes commit https://github.com/vim/vim/commit/dde60341115effc9789742c2f4565d184e98b6b5 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 30 14:55:42 2017 +0200 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.
author Christian Brabandt <cb@256bit.org>
date Wed, 30 Aug 2017 15:00:06 +0200
parents 399765ed6ff9
children 0a7890c55b1d
files src/testdir/test_windows_home.vim src/version.c
diffstat 2 files changed, 40 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_windows_home.vim
+++ b/src/testdir/test_windows_home.vim
@@ -38,76 +38,73 @@ func CheckHomeIsInSubprocessEnvironment(
 endfunc
 
 func CheckHome(exp, ...)
-  "call assert_equal(a:exp, $HOME)
-  "call assert_equal(a:exp, expand('~', ':p'))
+  call assert_equal(a:exp, $HOME)
+  call assert_equal(a:exp, expand('~', ':p'))
   if !a:0
     call CheckHomeIsMissingFromSubprocessEnvironment()
   else
-    call CheckHomeIsInSubprocessEnvironment(a:exp)
+    call CheckHomeIsInSubprocessEnvironment(a:1)
   endif
 endfunc
 
-func TestWindowsHome()
+func Test_WindowsHome()
   command! -nargs=* SaveEnv call <SID>save_env(<f-args>)
   command! -nargs=* RestoreEnv call <SID>restore_env()
   command! -nargs=* UnletEnv call <SID>unlet_env(<f-args>)
+  set noshellslash
 
-  SaveEnv $HOME $USERPROFILE $HOMEDRIVE $HOMEPATH
+  let save_home = $HOME
+  SaveEnv $USERPROFILE $HOMEDRIVE $HOMEPATH
   try
-    RestoreEnv
-    UnletEnv $HOME $USERPROFILE $HOMEPATH
-    let $HOMEDRIVE = 'C:'
-    call CheckHome('C:\')
-
-    RestoreEnv
-    UnletEnv $HOME $USERPROFILE
+    " Normal behavior: use $HOMEDRIVE and $HOMEPATH, ignore $USERPROFILE
+    let $USERPROFILE = 'unused'
     let $HOMEDRIVE = 'C:'
     let $HOMEPATH = '\foobar'
+    let $HOME = ''  " Force recomputing "homedir"
     call CheckHome('C:\foobar')
 
-    RestoreEnv
-    UnletEnv $HOME $HOMEDRIVE $HOMEPATH
-    let $USERPROFILE = 'C:\foo'
-    call CheckHome('C:\foo')
+    " Same, but with $HOMEPATH not set
+    UnletEnv $HOMEPATH
+    let $HOME = ''  " Force recomputing "homedir"
+    call CheckHome('C:\')
 
-    RestoreEnv
-    UnletEnv $HOME
+    " Use $USERPROFILE if $HOMEPATH and $HOMEDRIVE are empty
+    UnletEnv $HOMEDRIVE $HOMEPATH
     let $USERPROFILE = 'C:\foo'
-    let $HOMEDRIVE = 'C:'
-    let $HOMEPATH = '\baz'
+    let $HOME = ''  " Force recomputing "homedir"
     call CheckHome('C:\foo')
 
-    RestoreEnv
+    " If $HOME is set the others don't matter
     let $HOME = 'C:\bar'
-    let $USERPROFILE = 'C:\foo'
-    let $HOMEDRIVE = 'C:'
-    let $HOMEPATH = '\baz'
-    call CheckHome('C:\bar', 1)
+    let $USERPROFILE = 'unused'
+    let $HOMEDRIVE = 'unused'
+    let $HOMEPATH = 'unused'
+    call CheckHome('C:\bar', 'C:\bar')
 
-    RestoreEnv
-    let $HOME = '%USERPROFILE%\bar'
+    " If $HOME contains %USERPROFILE% it is expanded
     let $USERPROFILE = 'C:\foo'
-    let $HOMEDRIVE = 'C:'
-    let $HOMEPATH = '\baz'
-    call CheckHome('%USERPROFILE%\bar', 1)
+    let $HOME = '%USERPROFILE%\bar'
+    let $HOMEDRIVE = 'unused'
+    let $HOMEPATH = 'unused'
+    call CheckHome('C:\foo\bar', '%USERPROFILE%\bar')
 
-    RestoreEnv
-    let $HOME = '%USERPROFILE'
+    " Invalid $HOME is kept
     let $USERPROFILE = 'C:\foo'
-    let $HOMEDRIVE = 'C:'
-    let $HOMEPATH = '\baz'
-    call CheckHome('%USERPROFILE', 1)
+    let $HOME = '%USERPROFILE'
+    let $HOMEDRIVE = 'unused'
+    let $HOMEPATH = 'unused'
+    call CheckHome('%USERPROFILE', '%USERPROFILE')
 
-    RestoreEnv
+    " %USERPROFILE% not at start of $HOME is not expanded
+    let $USERPROFILE = 'unused'
     let $HOME = 'C:\%USERPROFILE%'
-    let $USERPROFILE = 'C:\foo'
-    let $HOMEDRIVE = 'C:'
-    let $HOMEPATH = '\baz'
-    call CheckHome('C:\%USERPROFILE%', 1)
+    let $HOMEDRIVE = 'unused'
+    let $HOMEPATH = 'unused'
+    call CheckHome('C:\%USERPROFILE%', 'C:\%USERPROFILE%')
 
     if has('channel')
       RestoreEnv
-      UnletEnv $HOME
+      let $HOME = save_home
       let env = ''
       let job = job_start('cmd /c set', {'out_cb': {ch,x->[env,execute('let env=x')]}})
       sleep 1
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1017,
+/**/
     1016,
 /**/
     1015,