Skip to content

Commit 2eb1b00

Browse files
committed
test(ALL): fix tests that fail when using git worktree
Details: - When using git worktree, the mini.nvim repository is also checked-out under a different name. That causes some tests to fail. - test_tabline: The tabline in test 'deduplicates named labels' changes when the cwd is not 'mini.nvim'. Solution: first cd into a subfolder also having 9 characters in the name. - test_snippets: The screenshot in 'Session persists after :edit' assumes that the name of the repro is mini.nvim. Solution: use a dummy statusline.
1 parent 9d35922 commit 2eb1b00

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

tests/screenshots/tests-test_snippets.lua---Session---persists-after-`-edit`

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
4|~
66
5|~
77
6|~
8-
7|</mini.nvim/tests/dir-snippets/tmp 1,4-5
8+
7|Dummy statusline
99
8|-- INSERT --
1010

1111
-|---------|---------|---------|---------|

tests/test_snippets.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3550,6 +3550,9 @@ T['Session']['persists after `:edit`'] = function()
35503550
child.cmd('edit')
35513551
sleep(small_time)
35523552

3553+
-- Ensure expect_screenshot succeeds regardless of actual path
3554+
child.o.statusline = 'Dummy statusline'
3555+
35533556
-- Should preserve both highlighting and data
35543557
validate_active_session()
35553558
child.expect_screenshot()

tests/test_tabline.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,20 +356,20 @@ T['make_tabline_string()']['deduplicates named labels'] = function()
356356
eq(eval_tabline(), ' dir1/aaa dir2/aaa dir1/dir_nested/aaa dir2/dir_nested/aaa ')
357357

358358
-- Should work for buffers without initial path
359+
local expected = ' dir1/aaa dir2/aaa dir1/dir_nested/aaa dir2/dir_nested/aaa '
359360
local buf_id = child.api.nvim_create_buf(true, false)
360361
child.api.nvim_buf_set_name(buf_id, 'aaa')
361-
local cur_dir_basename = child.fn.fnamemodify(child.fn.getcwd(), ':t')
362-
eq(
363-
eval_tabline(),
364-
(' dir1/aaa dir2/aaa dir1/dir_nested/aaa dir2/dir_nested/aaa %s/aaa '):format(cur_dir_basename)
365-
)
362+
-- Avoid truncation by ensuring that width is large enough to also hold part of cwd
363+
expected = expected .. (' %s/aaa '):format(child.fn.fnamemodify(child.fn.getcwd(), ':t'))
364+
child.o.columns = #expected
365+
eq(eval_tabline(), expected)
366366
end
367367

368368
T['make_tabline_string()']['deduplicates independent of current working directory'] = function()
369369
edit_path('dir1/aaa')
370370
edit_path('dir1/dir_nested/aaa')
371371

372-
child.cmd('cd tests/dir-tabline/dir1')
372+
child.fn.chdir('tests/dir-tabline/dir1')
373373
eq(eval_tabline(), ' dir1/aaa dir_nested/aaa ')
374374
end
375375

0 commit comments

Comments
 (0)