-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
147aaa9
commit 7d09bf5
Showing
11 changed files
with
1,008 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,45 @@ | ||
TESTS_INIT=tests/minimal_init.lua | ||
TESTS_DIR=tests/ | ||
TESTS_INIT = tests/minimal_init.lua | ||
# 30 mins | ||
TIMEOUT_MINS=30*60*1000 | ||
TIMEOUT_MINS := $(shell echo $$((30 * 60 * 1000))) | ||
|
||
|
||
.PHONY: test | ||
.PHONY: test-demo | ||
.PHONY: test-demo-main | ||
.PHONY: test-demo-config | ||
|
||
test: | ||
@nvim \ | ||
--headless \ | ||
--noplugin \ | ||
-u ${TESTS_INIT} \ | ||
-c "PlenaryBustedDirectory ${TESTS_DIR} { minimal_init = '${TESTS_INIT}', timeout = ${TIMEOUT_MINS} }" | ||
-c "lua require([[plenary.test_harness]]).test_directory([[tests ! -regex .*_demo_spec.*]], { minimal_init = '"${TESTS_INIT}"', timeout = "${TIMEOUT_MINS}", })" | ||
|
||
test-all: | ||
@nvim \ | ||
--headless \ | ||
--noplugin \ | ||
-u ${TESTS_INIT} \ | ||
-c "lua require([[plenary.test_harness]]).test_directory([[tests]], { minimal_init = '"${TESTS_INIT}"', timeout = "${TIMEOUT_MINS}", })" | ||
|
||
test-demo: | ||
@nvim \ | ||
--headless \ | ||
--noplugin \ | ||
-u ${TESTS_INIT} \ | ||
-c "lua require([[plenary.test_harness]]).test_directory([[tests -regex .*_demo_spec.*]], { minimal_init = '"${TESTS_INIT}"', timeout = "${TIMEOUT_MINS}", })" | ||
|
||
test-demo-main: | ||
@nvim \ | ||
--headless \ | ||
--noplugin \ | ||
-u ${TESTS_INIT} \ | ||
-c "lua require([[plenary.test_harness]]).test_directory([[tests -name kitty_scrollback_demo_spec.lua]], { minimal_init = '"${TESTS_INIT}"', timeout = "${TIMEOUT_MINS}", })" | ||
|
||
test-demo-config: | ||
@nvim \ | ||
--headless \ | ||
--noplugin \ | ||
-u ${TESTS_INIT} \ | ||
-c "lua require([[plenary.test_harness]]).test_directory([[tests -name kitty_scrollback_config_demo_spec.lua]], { minimal_init = '"${TESTS_INIT}"', timeout = "${TIMEOUT_MINS}", })" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# thanks https://github.com/kalgynirae/dotfiles/blob/1203030bd44448088c4c1a42155a254171a31c4b/bashrc#L59 | ||
# Test the terminal's text/color capabilities | ||
colortest() { | ||
local color escapes intensity style | ||
echo "NORMAL bold dim itali under rever strik BRIGHT bold dim itali under rever strik" | ||
for color in $(seq 0 7); do | ||
for intensity in 3 9; do # normal, bright | ||
escapes="${intensity}${color}" | ||
printf '\e[%sm\\e[%sm\e[0m ' "$escapes" "$escapes" # normal | ||
for style in 1 2 3 4 7 9; do # bold, dim, italic, underline, reverse, strikethrough | ||
escapes="${intensity}${color};${style}" | ||
printf '\e[%sm\\e[%sm\e[0m ' "$escapes" "$style" | ||
done | ||
echo -n " " | ||
done | ||
echo | ||
done | ||
echo -n "TRUECOLOR " | ||
awk 'BEGIN{ | ||
columns = 78; | ||
step = columns / 6; | ||
for (hue = 0; hue<columns; hue++) { | ||
x = (hue % step) * 255 / step; | ||
if (hue < step) { | ||
r = 255; g = x; b = 0; | ||
} else if (hue < step*2) { | ||
r = 255-x; g = 255; b = 0; | ||
} else if (hue < step*3) { | ||
r = 0; g = 255; b = x; | ||
} else if (hue < step*4) { | ||
r = 0; g = 255-x; b = 255; | ||
} else if (hue < step*5) { | ||
r = x; g = 0; b = 255; | ||
} else { | ||
r = 255; g = 0; b = 255-x; | ||
} | ||
printf "\033[48;2;%d;%d;%dm", r, g, b; | ||
printf "\033[38;2;%d;%d;%dm", 255-r, 255-g, 255-b; | ||
printf " \033[0m"; | ||
} | ||
printf "\n"; | ||
}' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
169 changes: 169 additions & 0 deletions
169
tests/kitty-scrollback/kitty_scrollback_config_demo_spec.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
local assert = require('luassert.assert') | ||
local h = require('tests.helpers') | ||
local describe = describe ---@diagnostic disable-line: undefined-global | ||
local it = it ---@diagnostic disable-line: undefined-global | ||
local after_each = after_each ---@diagnostic disable-line: undefined-global | ||
local before_each = before_each ---@diagnostic disable-line: undefined-global | ||
|
||
h.setup_backport() | ||
|
||
local ksb_dir = vim.fn.fnamemodify( | ||
vim.fn.fnamemodify(vim.api.nvim_get_runtime_file('lua/kitty-scrollback', false)[1], ':h:h'), | ||
':p' | ||
) | ||
h.debug({ | ||
ksb_dir = ksb_dir, | ||
kitty_conf = ksb_dir .. 'tests/kitty.conf', | ||
}) | ||
|
||
local tmpsock = h.tempsocket(ksb_dir .. 'tmp/') | ||
local kitty_instance | ||
|
||
local shell = h.debug(h.is_github_action and '/bin/bash' or (vim.o.shell .. ' --noprofile --norc')) | ||
|
||
local kitty_cmd = h.debug({ | ||
'kitty', | ||
'--listen-on=unix:' .. tmpsock, | ||
'--config', | ||
ksb_dir .. 'tests/kitty.conf', | ||
'--override', | ||
'shell=' .. shell, | ||
'--override', | ||
'enabled_layouts=fat:bias=90', | ||
'--override', | ||
'initial_window_width=161c', | ||
'--override', | ||
'initial_window_height=30c', | ||
'--override', | ||
'font_size=18.0', | ||
'--override', | ||
'background_opacity=1.0', | ||
'--session', | ||
'-', -- read session from stdin | ||
}) | ||
|
||
local cowthink_stdout = vim | ||
.system({ 'cowthink', '-f', '/opt/homebrew/share/cows/stegosaurus.cow', 'nice @' .. h.now() }) | ||
:wait().stdout or '' | ||
|
||
describe('kitty-scrollback.nvim', function() | ||
before_each(function() | ||
vim.fn.mkdir(ksb_dir .. 'tests/workdir', 'p') | ||
kitty_instance = vim.system(kitty_cmd, { | ||
stdin = 'cd ' .. ksb_dir, | ||
}) | ||
local ready = false | ||
vim.fn.wait(5000, function() | ||
ready = (h.debug(h.kitty_remote_ls():wait()).code == 0) | ||
return ready | ||
end, 500) | ||
|
||
assert.is_true(ready, 'kitty is not ready for remote connections, exiting') | ||
h.pause() | ||
|
||
local ksb_work_dir = os.getenv('KITTY_SCROLLBACK_NVIM_DIR') or 'tmp/kitty-scrollback.nvim' | ||
local is_directory = vim.fn.isdirectory(ksb_work_dir) > 0 | ||
if is_directory then | ||
vim.system({ 'rm', '-rf', ksb_work_dir }):wait() | ||
end | ||
vim | ||
.system({ | ||
'git', | ||
'clone', | ||
'https://github.com/mikesmithgh/kitty-scrollback.nvim', | ||
ksb_work_dir, | ||
}) | ||
:wait() | ||
|
||
h.feed_kitty({ | ||
[[source ]] .. ksb_dir .. [[tests/bashrc]], | ||
[[\n]], -- enter | ||
[[cd ]] .. ksb_work_dir, | ||
[[\n]], -- enter | ||
[[clear]], | ||
[[\n]], -- enter | ||
}) | ||
end) | ||
|
||
after_each(function() | ||
kitty_instance:kill(2) | ||
kitty_instance = nil | ||
end) | ||
|
||
it('should demo', function() | ||
h.assert_screen_equals( | ||
h.feed_kitty({ | ||
[[ | ||
printf "\\033[0m\\033[38;2;167;192;128m\\n" && | ||
figlet -f cyberlarge -c -w 165 kitty-scrollback.nvim && | ||
printf "\\033[0m\\n" | ||
eza --tree --icons ../kitty-scrollback.nvim/lua | ||
lolcat --freq=0.15 --spread=1.5 --truecolor - | ||
]], | ||
[[__next_as_line]], | ||
cowthink_stdout, | ||
[[\x04]], -- control+d | ||
[[ | ||
figlet -f cyberlarge -c -w 165 kitty-scrollback.nvim | lolcat]], | ||
[[\n]], -- enter | ||
[[ | ||
colortest | ||
]], | ||
[[\n]], -- enter | ||
[[__open_ksb]], | ||
[[a# builtin > kitty_scrollback_nvim]], | ||
[[\e]], -- esc | ||
[[0o]], | ||
[[ | ||
default configuration for the keymap `kitty_mod+h` | ||
Browse scrollback buffer in kitty-scrollback.nvim | ||
]], | ||
[[\e]], -- esc | ||
[[gg0]], | ||
}), | ||
{ | ||
stdout = h.with_status_win( | ||
[[ | ||
_____ ..-~ ~-..-~ | ||
| | \~~~\.' `./~~~/ | ||
--------- \__/ \__/ | ||
.' O \ / / \ " | ||
(_____, `._.' | } \/~~~/ | ||
`----. / } | / \__/ | ||
`-. | / | / `. ,~~| | ||
~-.__| /_ - ~ ^| /- _ `..-' | ||
| / | / ~-. `-. _ _ _ | ||
|_____| |_____| ~ - . _ _ _ _ _> | ||
$ figlet -f cyberlarge -c -w 165 kitty-scrollback.nvim | lolcat | ||
_ _ _____ _______ _______ __ __ _______ _______ ______ _____ ______ _______ _______ _ _ __ _ _ _ _____ _______ | ||
|____/ | | | \_/ ___ |______ | |_____/ | | | | |_____] |_____| | |____/ | \ | \ / | | | | | ||
| \_ __|__ | | | ______| |_____ | \_ |_____| |_____ |_____ |_____] | | |_____ | \_ . | \_| \/ __|__ | | | | ||
$🭽▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔🭾 | ||
N▏# builtin > kitty_scrollback_nvim ▕ | ||
\▏# default configuration for the keymap `kitty_mod+h` ▕ | ||
\▏# ▕ | ||
\▏# Browse scrollback buffer in kitty-scrollback.nvim ▕ | ||
\▏# ▕ | ||
\▏ ▕ | ||
\▏ ▕ | ||
\▏ ▕ | ||
\▏ ▕ | ||
T▏ ▕ | ||
$🭼▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁🭿 | ||
$▏ ▕ | ||
$▏ \y Yank <C-CR> Execute <S-CR> Paste :w Paste g? Toggle Mappings ▕ | ||
$🭼▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁🭿 | ||
]], | ||
168 | ||
), | ||
cursor_y = 17, | ||
cursor_x = 3, | ||
}, | ||
'kitty-scrollback.nvim did not position cursor on first line' | ||
) | ||
end) | ||
end) |
Oops, something went wrong.