mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: "$PATHEXT=::"
This commit is contained in:
parent
70a0a12b53
commit
c7039fd0d3
@ -297,9 +297,9 @@ static bool is_executable(const char *name, char_u **abspath)
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
/// Checks if file `name` is executable under one of these conditions:
|
||||
/// - if the file extension is in $PATHEXT and `name` is executable
|
||||
/// - if the result of any $PATHEXT extension appended to `name` is executable
|
||||
/// Checks if file `name` is executable under any of these conditions:
|
||||
/// - extension is in $PATHEXT and `name` is executable
|
||||
/// - result of any $PATHEXT extension appended to `name` is executable
|
||||
static bool is_executable_ext(char *name, char_u **abspath)
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
@ -318,7 +318,7 @@ static bool is_executable_ext(char *name, char_u **abspath)
|
||||
if (is_executable(name, abspath)) {
|
||||
return true;
|
||||
}
|
||||
// Skip the extension.
|
||||
// Skip it.
|
||||
ext++;
|
||||
continue;
|
||||
}
|
||||
|
@ -136,7 +136,14 @@ describe('executable() (Windows)', function()
|
||||
eq(1, call('executable', '.\\test_executable_zzz'))
|
||||
end)
|
||||
|
||||
it('returns 1 for any existing filename, when a Unix-shell like \'shell\'', function()
|
||||
it("with weird $PATHEXT", function()
|
||||
clear({env={PATHEXT=';'}})
|
||||
eq(0, call('executable', '.\\test_executable_zzz'))
|
||||
clear({env={PATHEXT=';;;.zzz;;'}})
|
||||
eq(1, call('executable', '.\\test_executable_zzz'))
|
||||
end)
|
||||
|
||||
it("unqualified filename, Unix-style 'shell'", function()
|
||||
clear({env={PATHEXT=''}})
|
||||
command('set shell=sh')
|
||||
for _,ext in ipairs(exts) do
|
||||
@ -145,7 +152,7 @@ describe('executable() (Windows)', function()
|
||||
eq(1, call('executable', 'test_executable_zzz.zzz'))
|
||||
end)
|
||||
|
||||
it('returns 1 for any existing path, when a Unix-shell like \'shell\' (backslashes)', function()
|
||||
it("relative path, Unix-style 'shell' (backslashes)", function()
|
||||
clear({env={PATHEXT=''}})
|
||||
command('set shell=bash.exe')
|
||||
for _,ext in ipairs(exts) do
|
||||
@ -156,7 +163,7 @@ describe('executable() (Windows)', function()
|
||||
eq(1, call('executable', './test_executable_zzz.zzz'))
|
||||
end)
|
||||
|
||||
it('returns 1 for any existing filename, when $PATHEXT contain dot itself', function()
|
||||
it('unqualified filename, $PATHEXT contains dot', function()
|
||||
clear({env={PATHEXT='.;.zzz'}})
|
||||
for _,ext in ipairs(exts) do
|
||||
eq(1, call('executable', 'test_executable_'..ext..'.'..ext))
|
||||
@ -169,7 +176,7 @@ describe('executable() (Windows)', function()
|
||||
eq(1, call('executable', 'test_executable_zzz.zzz'))
|
||||
end)
|
||||
|
||||
it('returns 1 for any existing path, when $PATHEXT contain dot itself (backslashes)', function()
|
||||
it('relative path, $PATHEXT contains dot (backslashes)', function()
|
||||
clear({env={PATHEXT='.;.zzz'}})
|
||||
for _,ext in ipairs(exts) do
|
||||
eq(1, call('executable', '.\\test_executable_'..ext..'.'..ext))
|
||||
@ -179,12 +186,12 @@ describe('executable() (Windows)', function()
|
||||
eq(1, call('executable', './test_executable_zzz.zzz'))
|
||||
end)
|
||||
|
||||
it('ignore case of extension', function()
|
||||
it('ignores case of extension', function()
|
||||
clear({env={PATHEXT='.ZZZ'}})
|
||||
eq(1, call('executable', 'test_executable_zzz.zzz'))
|
||||
end)
|
||||
|
||||
it('file is not found by relative path from $PATH', function()
|
||||
it('relative path does not search $PATH', function()
|
||||
clear({env={PATHEXT=''}})
|
||||
eq(0, call('executable', './System32/notepad.exe'))
|
||||
eq(0, call('executable', '.\\System32\\notepad.exe'))
|
||||
|
@ -5,7 +5,7 @@ local eq, clear, call, iswin =
|
||||
describe('exepath() (Windows)', function()
|
||||
if not iswin() then return end -- N/A for Unix.
|
||||
|
||||
it('append extension, even if omit extension', function()
|
||||
it('append extension if omitted', function()
|
||||
local filename = 'cmd'
|
||||
local pathext = '.exe'
|
||||
clear({env={PATHEXT=pathext}})
|
||||
|
Loading…
Reference in New Issue
Block a user