patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe
Problem: MS-Windows: exepath() works different from cmd.exe.
Solution: Make exepath() work better on MS-Windows. (closes #6115)
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index e5c74e0..9b5d976 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1187,6 +1187,30 @@
call assert_equal(0, executable('notepad.exe.exe'))
call assert_equal(0, executable('shell32.dll'))
call assert_equal(0, executable('win.ini'))
+
+ " get "notepad" path and remove the leading drive and sep. (ex. 'C:\')
+ let notepadcmd = exepath('notepad.exe')
+ let driveroot = notepadcmd[:2]
+ let notepadcmd = notepadcmd[3:]
+ new
+ " check that the relative path works in /
+ execute 'lcd' driveroot
+ call assert_equal(1, executable(notepadcmd))
+ call assert_equal(driveroot .. notepadcmd, notepadcmd->exepath())
+ bwipe
+
+ " create "notepad.bat"
+ call mkdir('Xdir')
+ let notepadbat = fnamemodify('Xdir/notepad.bat', ':p')
+ call writefile([], notepadbat)
+ new
+ " check that the path and the pathext order is valid
+ lcd Xdir
+ let [pathext, $PATHEXT] = [$PATHEXT, '.com;.exe;.bat;.cmd']
+ call assert_equal(notepadbat, exepath('notepad'))
+ let $PATHEXT = pathext
+ bwipe
+ eval 'Xdir'->delete('rf')
elseif has('unix')
call assert_equal(1, 'cat'->executable())
call assert_equal(0, executable('nodogshere'))