ide: test typing, a person's own plugin and a custom prefix
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
4 files changed
+69
-6
No files matched your search
@@ -1,7 +1,6 @@
|
||||
# LLeMbas IDE
|
||||
|
||||
LLeMbas in your editor: a Neovim plugin, a VS Code / VSCodium extension, and LLeMbas IDE, a
|
||||
complete Neovim editor with the plugin built in.
|
||||
LLeMbas in your editor: a Neovim plugin, and a VS Code / VSCodium extension.
|
||||
|
||||
Both are clients of the [LLeMbas CLI](https://github.com/LLeMbas/LLeMbas-CLI). The CLI is the agent:
|
||||
it holds the sign-in to your LLeMbas server, the models, the tools and the permissions. The editor
|
||||
|
||||
@@ -325,7 +325,10 @@ local function run()
|
||||
-- The person's own file.
|
||||
check("lua/user/init.lua exists, and is loaded last when it says something", function()
|
||||
eq(vim.fn.filereadable(vim.fn.stdpath("config") .. "/lua/user/init.lua"), 1)
|
||||
if vim.env.IDE_TEST_USER == "1" then eq(vim.g.llembas_ide_test_user, 42) end
|
||||
if vim.env.IDE_TEST_USER == "1" then
|
||||
eq(vim.g.llembas_ide_test_user, 42)
|
||||
eq(vim.g.llembas_ide_test_plugin, "loaded", "the person's own plugin in pack/user/start")
|
||||
end
|
||||
end)
|
||||
|
||||
vim.g.llembas_ide_no_session = true
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
-- Typing in the installed IDE, headless: the completion menu opens from the buffer's words, and
|
||||
-- the keys are the ones the README promises.
|
||||
-- llembas-ide --headless -c "luafile ide/tests/typing.lua"
|
||||
local function finish(problems)
|
||||
vim.g.llembas_ide_no_session = true
|
||||
io.stdout:write("\n")
|
||||
for _, p in ipairs(problems) do io.stdout:write("FAIL " .. p .. "\n") end
|
||||
io.stdout:write(("ide-typing: %s\n"):format(#problems == 0 and "the menu opens, <Tab> is not the menu's" or #problems .. " failed"))
|
||||
vim.cmd(#problems == 0 and "qa!" or "cquit 1")
|
||||
end
|
||||
|
||||
vim.schedule(function()
|
||||
vim.cmd("enew")
|
||||
vim.api.nvim_buf_set_lines(0, 0, -1, false, { "alphabet_soup = 1", "alphabet_city = 2", "" })
|
||||
vim.api.nvim_win_set_cursor(0, { 3, 0 })
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("ialph", true, false, true), "tx!", false)
|
||||
end)
|
||||
|
||||
local waited = 0
|
||||
local function look()
|
||||
waited = waited + 200
|
||||
local blink = require("blink.cmp")
|
||||
if not blink.is_visible() and waited < 6000 then return vim.defer_fn(look, 200) end
|
||||
local problems = {}
|
||||
if not blink.is_visible() then table.insert(problems, "the completion menu did not open on typed text") end
|
||||
local items = require("blink.cmp.completion.list").items or {}
|
||||
local labels = {}
|
||||
for _, item in ipairs(items) do labels[item.label] = true end
|
||||
if not (labels.alphabet_soup and labels.alphabet_city) then table.insert(problems, "the buffer's words are not offered: " .. vim.inspect(vim.tbl_keys(labels))) end
|
||||
if require("blink.cmp.completion.list").selected_item_idx ~= nil then table.insert(problems, "an entry is chosen before the person moved") end
|
||||
local tab = vim.fn.maparg("<Tab>", "i", false, true)
|
||||
if tab.buffer == 1 then table.insert(problems, "<Tab> is mapped in the buffer while only the menu is showing: " .. vim.inspect(tab.desc)) end
|
||||
if vim.fn.maparg("<CR>", "i", false, true).buffer ~= 1 or vim.fn.maparg("<C-y>", "i", false, true).buffer ~= 1 then
|
||||
table.insert(problems, "the menu's <CR> and <C-y> are not mapped")
|
||||
end
|
||||
if vim.api.nvim_buf_get_lines(0, 2, 3, false)[1] ~= "alph" then table.insert(problems, "the typed text was changed: " .. vim.api.nvim_buf_get_lines(0, 2, 3, false)[1]) end
|
||||
finish(problems)
|
||||
end
|
||||
vim.defer_fn(look, 200)
|
||||
+25
-3
@@ -108,6 +108,11 @@ headless() {
|
||||
IDE_TEST_BG_LIGHT="$BG_LIGHT" "$@" timeout 120 "$home/.local/bin/llembas-ide" --headless \
|
||||
-c "luafile $REPO/ide/tests/headless.lua" 2>&1)
|
||||
}
|
||||
typing() { # the completion menu, through the launcher
|
||||
local home="$1" out
|
||||
out="$( (cd "$WORK" && as "$home" timeout 60 "$home/.local/bin/llembas-ide" --headless -c "luafile $REPO/ide/tests/typing.lua" 2>&1) || true)"
|
||||
if grep -q -F 'ide-typing: the menu opens' <<<"$out"; then ok "$2"; else fail "$2" "$out"; fi
|
||||
}
|
||||
report_headless() { # report_headless "name" "output"
|
||||
local line
|
||||
line="$(grep -o -E 'ide-headless: [0-9]+ passed, 0 failed.*' <<<"$2" || true)"
|
||||
@@ -210,6 +215,7 @@ expect "--version: the IDE" "$out" "LLeMbas IDE $VERSION"
|
||||
expect "--version: Neovim" "$out" "Neovim $("$SYSTEM_NVIM" --version | sed -n '1s/^NVIM v//p')"
|
||||
expect "--version: the plugin" "$out" "LLeMbas plugin $VERSION"
|
||||
report_headless "headless start, from the inside" "$(headless "$A" 0 IDE_TEST_FIRST=1 || true)"
|
||||
typing "$A" "typing: the completion menu opens with the buffer's words, and <Tab> stays LLeMbas's"
|
||||
attempt as "$A" "$A/.local/bin/llembas-ide" doctor
|
||||
out="$OUT"
|
||||
passes "doctor finds the installation sound"
|
||||
@@ -225,6 +231,9 @@ expect "arguments go through to Neovim" "$out" "llembas-ide some-file.txt"
|
||||
# --- 4. again: an update in place --------------------------------------------------------------
|
||||
echo "Installing again"
|
||||
echo 'vim.g.llembas_ide_test_user = 42' >>"$A/.config/llembas-ide/lua/user/init.lua"
|
||||
# A plugin of the person's own, in the directory the README names.
|
||||
mkdir -p "$A/.config/llembas-ide/pack/user/start/mine/plugin"
|
||||
echo 'vim.g.llembas_ide_test_plugin = "loaded"' >"$A/.config/llembas-ide/pack/user/start/mine/plugin/mine.lua"
|
||||
user_before="$(sha256sum "$A/.config/llembas-ide/lua/user/init.lua")"
|
||||
attempt installer "$A" --from-checkout --nvim-bin "$SYSTEM_NVIM" --no-parsers
|
||||
out="$OUT"
|
||||
@@ -351,6 +360,7 @@ passes "installs from the release, with the pinned Neovim downloaded and the gra
|
||||
expect "the installed Neovim is the pinned one" "$out" "Neovim $(cat ide/neovim.version)"
|
||||
check "it is the IDE's own copy" test -x "$B/.local/share/llembas-ide/nvim/bin/nvim"
|
||||
report_headless "headless start on the pinned Neovim with compiled grammars" "$(headless "$B" 1 IDE_TEST_FIRST=1 || true)"
|
||||
typing "$B" "typing on the pinned Neovim: the completion menu opens, and <Tab> stays LLeMbas's"
|
||||
attempt as "$B" "$B/.local/bin/llembas-ide" doctor
|
||||
out="$OUT"
|
||||
passes "doctor finds it sound"
|
||||
@@ -380,13 +390,25 @@ if [ "$QUICK" != 1 ]; then
|
||||
expect "and the compiled grammars" "$out" "compiled Treesitter grammars (already installed, same pins)"
|
||||
fi
|
||||
|
||||
# --- 8. uninstalling ---------------------------------------------------------------------------
|
||||
# --- 8. somewhere else: --prefix -----------------------------------------------------------------
|
||||
echo "A prefix of the person's choosing"
|
||||
D="$WORK/d"
|
||||
mkdir -p "$D"
|
||||
attempt installer "$D" --from-checkout --nvim-bin "$SYSTEM_NVIM" --no-parsers --prefix "$WORK/opt/my ide"
|
||||
passes "installs into a directory with a space in its name"
|
||||
check "the IDE is there and not in the default place" test -d "$WORK/opt/my ide/lib" -a ! -e "$D/.local/share/llembas-ide"
|
||||
check "doctor is content" as "$D" "$D/.local/bin/llembas-ide" doctor
|
||||
attempt as "$D" "$D/.local/bin/llembas-ide" uninstall --purge --yes
|
||||
passes "uninstall --purge --yes"
|
||||
if [ -z "$(files_in "$D")" ] && [ ! -e "$WORK/opt/my ide" ]; then ok "leaves nothing, and the prefix is gone"; else fail "leaves nothing, and the prefix is gone" "$(files_in "$D"; ls -la "$WORK/opt")"; fi
|
||||
|
||||
# --- 9. uninstalling ---------------------------------------------------------------------------
|
||||
echo "Uninstalling"
|
||||
attempt as "$A" "$A/.local/bin/llembas-ide" uninstall --yes
|
||||
out="$OUT"
|
||||
passes "uninstall --yes"
|
||||
left="$(files_in "$A")"
|
||||
if [ "$left" = "./.config/llembas-ide/lua/user/init.lua" ]; then ok "leaves nothing but the person's own file"; else fail "leaves nothing but the person's own file" "$left"; fi
|
||||
left="$(files_in "$A" | tr '\n' ' ')"
|
||||
if [ "$left" = "./.config/llembas-ide/lua/user/init.lua ./.config/llembas-ide/pack/user/start/mine/plugin/mine.lua " ]; then ok "leaves nothing but the person's own file and plugin"; else fail "leaves nothing but the person's own file and plugin" "$left"; fi
|
||||
check "which still has what the person wrote" grep -q 'llembas_ide_test_user = 42' "$A/.config/llembas-ide/lua/user/init.lua"
|
||||
attempt as "$B" "$B/.local/bin/llembas-ide" uninstall --purge --yes
|
||||
out="$OUT"
|
||||
|
||||
Reference in new issue
Block a user