Skip to content

Commit

Permalink
chore: test stuff with socket
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmithgh committed Dec 6, 2023
1 parent e4f66ca commit a3f32ed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
23 changes: 18 additions & 5 deletions tests/helpers.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
local M = {}
local current_tmpsocket

local debug_enabled = vim.env.RUNNER_DEBUG == 1
vim.print('debug_enabled ' .. debug_enabled)

M.setup_backport = function()
if vim.fn.has('nvim-0.10') <= 0 then
-- vim.opt.runtimepath:append('/Users/mike/gitrepos/kitty-scrollback.nvim') -- TODO remove if not needed
Expand All @@ -12,8 +15,11 @@ M.now = function()
return vim.fn.strftime('%m-%d-%Y %H:%M:%S', vim.fn.localtime())
end

M.tempsocket = function()
local tmpdir = vim.system({ 'mktemp', '-d' }):wait().stdout:gsub('\n', '')
M.tempsocket = function(tmp_dir)
local result =
vim.system(vim.list_extend({ 'mktemp', '-d' }, tmp_dir and { '-p', tmp_dir } or {})):wait()
vim.print(result)
local tmpdir = result.stdout:gsub('\n', '')
current_tmpsocket = tmpdir .. '/kitty-scrollback-nvim.sock'
vim.print('socket ' .. current_tmpsocket)
return current_tmpsocket
Expand All @@ -29,15 +35,19 @@ end

M.kitty_remote_get_text = function(args, ...)
vim.print(table.concat(M.kitty_remote_get_text_cmd(args or {}), ' '))
return vim.system(M.kitty_remote_get_text_cmd(args or {}), ...):wait()
local result = vim.system(M.kitty_remote_get_text_cmd(args or {}), ...):wait()
vim.print(result)
return result
end

M.kitty_remote_send_text_cmd = function(txt)
return vim.list_extend(M.kitty_remote_cmd(), { 'send-text', txt })
end

M.kitty_remote_send_text = function(txt, ...)
return vim.system(M.kitty_remote_send_text_cmd(txt), ...):wait()
local result = vim.system(M.kitty_remote_send_text_cmd(txt), ...):wait()
vim.print(result)
return result
end

M.kitty_remote_set_title_cmd = function(title)
Expand All @@ -53,7 +63,9 @@ M.kitty_remote_close_window_cmd = function()
end

M.kitty_remote_close_window = function()
return vim.system(M.kitty_remote_close_window_cmd()):wait()
local result = vim.system(M.kitty_remote_close_window_cmd()):wait()
vim.print(result)
return result
end

M.kitty_remote_ls_cmd = function()
Expand Down Expand Up @@ -111,6 +123,7 @@ M.kitty_remote_kitten_kitty_scroll_prompt_and_pause = function(direction, select
local result = vim
.system(M.kitty_remote_kitten_kitty_scroll_prompt_cmd(direction, select_cmd_output), ...)
:wait()
vim.print(result)
M.pause(1)
return result
end
Expand Down
6 changes: 3 additions & 3 deletions tests/kitty-scrollback/kitty_scrollback_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ local before_each = before_each ---@diagnostic disable-line: undefined-global

h.setup_backport()

local tmpsock = h.tempsocket()
local kitty_instance

local ksb_dir = vim.fn.fnamemodify(
vim.fn.fnamemodify(vim.api.nvim_get_runtime_file('lua/kitty-scrollback', false)[1], ':h:h'),
':p'
)

local tmpsock = h.tempsocket(ksb_dir)
local kitty_instance

local kitty_cmd = {
'kitty',
'--listen-on=unix:' .. tmpsock,
Expand Down

0 comments on commit a3f32ed

Please sign in to comment.