Add spec/awful/completion_spec.lua
This commit is contained in:
parent
4c792b49a9
commit
0c97d1aa95
|
@ -40,8 +40,8 @@ install:
|
||||||
# See also `apt-cache showsrc awesome | grep -E '^(Version|Build-Depends)'`.
|
# See also `apt-cache showsrc awesome | grep -E '^(Version|Build-Depends)'`.
|
||||||
- sudo apt-get install -y libcairo2-dev gir1.2-gtk-3.0 xmlto asciidoc libpango1.0-dev libxcb-xtest0-dev libxcb-icccm4-dev libxcb-randr0-dev libxcb-keysyms1-dev libxcb-xinerama0-dev libdbus-1-dev libxdg-basedir-dev libstartup-notification0-dev imagemagick libxcb1-dev libxcb-shape0-dev libxcb-util0-dev libx11-xcb-dev libxcb-cursor-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev
|
- sudo apt-get install -y libcairo2-dev gir1.2-gtk-3.0 xmlto asciidoc libpango1.0-dev libxcb-xtest0-dev libxcb-icccm4-dev libxcb-randr0-dev libxcb-keysyms1-dev libxcb-xinerama0-dev libdbus-1-dev libxdg-basedir-dev libstartup-notification0-dev imagemagick libxcb1-dev libxcb-shape0-dev libxcb-util0-dev libx11-xcb-dev libxcb-cursor-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev
|
||||||
|
|
||||||
# Deps for functional tests.
|
# Deps for tests.
|
||||||
- sudo apt-get install -y dbus-x11 xterm xdotool xterm xvfb
|
- sudo apt-get install -y dbus-x11 xterm xdotool xterm xvfb zsh
|
||||||
|
|
||||||
# Need xorg-macros
|
# Need xorg-macros
|
||||||
- sudo apt-get install -y xutils-dev
|
- sudo apt-get install -y xutils-dev
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
local compl = require("awful.completion")
|
||||||
|
local shell = function(...)
|
||||||
|
local command, pos, matches = compl.shell(...)
|
||||||
|
return {command, pos, matches}
|
||||||
|
end
|
||||||
|
local gfs = require("gears.filesystem")
|
||||||
|
|
||||||
|
describe("awful.completion.shell in empty directory", function()
|
||||||
|
local orig_popen = io.popen
|
||||||
|
|
||||||
|
setup(function()
|
||||||
|
gfs.make_directories('/tmp/awesome-tests/empty')
|
||||||
|
io.popen = function(...) --luacheck: ignore
|
||||||
|
return orig_popen('cd /tmp/awesome-tests/empty && ' .. ...)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
teardown(function()
|
||||||
|
os.remove('/tmp/awesome-tests/empty')
|
||||||
|
io.popen = orig_popen --luacheck: ignore
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("handles completion of true", function()
|
||||||
|
assert.same(shell('true', 5, 1, 'zsh'), {'true', 5, {'true'}})
|
||||||
|
assert.same(shell('true', 5, 1, 'bash'), {'true', 5, {'true'}})
|
||||||
|
assert.same(shell('true', 5, 1, nil), {'true', 5, {'true'}})
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe("awful.completion.shell", function()
|
||||||
|
local orig_popen = io.popen
|
||||||
|
|
||||||
|
setup(function()
|
||||||
|
gfs.make_directories('/tmp/awesome-tests/dir')
|
||||||
|
os.execute('cd /tmp/awesome-tests/dir && touch localcommand && chmod +x localcommand')
|
||||||
|
io.popen = function(...) --luacheck: ignore
|
||||||
|
return orig_popen('cd /tmp/awesome-tests/dir && ' .. ...)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
teardown(function()
|
||||||
|
os.remove('/tmp/awesome-tests/dir')
|
||||||
|
io.popen = orig_popen --luacheck: ignore
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("handles empty input", function()
|
||||||
|
assert.same(shell('', 1, 1, 'zsh'), {'', 1})
|
||||||
|
assert.same(shell('', 1, 1, 'bash'), {'', 1})
|
||||||
|
assert.same(shell('', 1, 1, nil), {'', 1})
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("completes local command", function()
|
||||||
|
assert.same(shell('./localcomm', 12, 1, 'zsh'), {'./localcommand', 15, {'./localcommand'}})
|
||||||
|
assert.same(shell('./localcomm', 12, 1, 'bash'), {'./localcommand', 15, {'./localcommand'}})
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("completes local file", function()
|
||||||
|
assert.same(shell('ls ', 4, 1, 'zsh'), {'ls localcommand', 16, {'localcommand'}})
|
||||||
|
assert.same(shell('ls ', 4, 1, 'bash'), {'ls localcommand', 16, {'localcommand'}})
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- vim: ft=lua:et:sw=4:ts=8:sts=4:tw=80
|
Loading…
Reference in New Issue