tests: Use pending() instead of silently skipping test. #2737

This commit is contained in:
Florian Walch 2015-05-25 09:45:17 +03:00
parent 412d246be7
commit 122890463a
2 changed files with 27 additions and 19 deletions

View File

@ -184,14 +184,16 @@ describe('system()', function()
end) end)
end) end)
if xclip then
describe("with a program that doesn't close stdout", function() describe("with a program that doesn't close stdout", function()
if not xclip then
pending('skipped (missing xclip)')
else
it('will exit properly after passing input', function() it('will exit properly after passing input', function()
eq('', eval([[system('xclip -i -selection clipboard', 'clip-data')]])) eq('', eval([[system('xclip -i -selection clipboard', 'clip-data')]]))
eq('clip-data', eval([[system('xclip -o -selection clipboard')]])) eq('clip-data', eval([[system('xclip -o -selection clipboard')]]))
end) end)
end)
end end
end)
describe('command passed as a list', function() describe('command passed as a list', function()
it('does not execute &shell', function() it('does not execute &shell', function()
@ -361,14 +363,16 @@ describe('systemlist()', function()
end) end)
end) end)
if xclip then
describe("with a program that doesn't close stdout", function() describe("with a program that doesn't close stdout", function()
if not xclip then
pending('skipped (missing xclip)')
else
it('will exit properly after passing input', function() it('will exit properly after passing input', function()
eq({}, eval( eq({}, eval(
"systemlist('xclip -i -selection clipboard', ['clip', 'data'])")) "systemlist('xclip -i -selection clipboard', ['clip', 'data'])"))
eq({'clip', 'data'}, eval( eq({'clip', 'data'}, eval(
"systemlist('xclip -o -selection clipboard')")) "systemlist('xclip -o -selection clipboard')"))
end) end)
end)
end end
end)
end) end)

View File

@ -268,9 +268,11 @@ describe('fs function', function()
return eq(gid, lfs.attributes(filename, 'gid')) return eq(gid, lfs.attributes(filename, 'gid'))
end) end)
it('owner of a file may change the group of the file to any group of which that owner is a member', function()
-- Some systems may not have `id` utility. -- Some systems may not have `id` utility.
if (os.execute('id -G > /dev/null 2>&1') == 0) then if (os.execute('id -G > /dev/null 2>&1') ~= 0) then
pending('skipped (missing `id` utility)')
else
it('owner of a file may change the group of the file to any group of which that owner is a member', function()
local file_gid = lfs.attributes(filename, 'gid') local file_gid = lfs.attributes(filename, 'gid')
-- Gets ID of any group of which current user is a member except the -- Gets ID of any group of which current user is a member except the
@ -288,17 +290,19 @@ describe('fs function', function()
eq(0, (os_fchown(filename, -1, new_gid))) eq(0, (os_fchown(filename, -1, new_gid)))
eq(new_gid, (lfs.attributes(filename, 'gid'))) eq(new_gid, (lfs.attributes(filename, 'gid')))
end end
end
end) end)
end
it('returns nonzero if process has not enough permissions', function()
-- On Windows `os_fchown` always returns 0 -- On Windows `os_fchown` always returns 0
-- because `uv_fs_chown` is no-op on this platform. -- because `uv_fs_chown` is no-op on this platform.
if (ffi.os ~= 'Windows' and ffi.C.geteuid() ~= 0) then if (ffi.os == 'Windows' or ffi.C.geteuid() == 0) then
pending('skipped (os_fchown is no-op on Windows)')
else
it('returns nonzero if process has not enough permissions', function()
-- chown to root -- chown to root
neq(0, os_fchown(filename, 0, 0)) neq(0, os_fchown(filename, 0, 0))
end
end) end)
end
end) end)
describe('os_file_is_readonly', function() describe('os_file_is_readonly', function()