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