test: unreliable swapfile_preserve_recover_spec

Problem:
Test sometimes fails on bsd (cirrus ci):

    test/functional/ex_cmds/swapfile_preserve_recover_spec.lua:589: retry() attempts: 464
    test/functional/ex_cmds/swapfile_preserve_recover_spec.lua:590: Expected objects to be the same.
    Passed in:
    (table: 0x0d5f1aa44070) {
      [1] = ''
     *[2] = ''
      [3] = '[Process exited 1]' }
    Expected:
    (table: 0x0d5ea3eb8718) {
      [1] = ''
     *[2] = '[Process exited 1]'
      [3] = '' }
    stack traceback:
      test/testutil.lua:104: in function 'retry'
      test/functional/ex_cmds/swapfile_preserve_recover_spec.lua:589: in function <test/functional/ex_cmds/swapfile_preserve_recover_spec.lua:556>

Solution:
Filter out empty items to avoid irrelevant redraw-timing assumptions.
This commit is contained in:
Justin M. Keyes
2025-02-26 22:51:48 +01:00
parent be1fbe38b3
commit 4a997a1732

View File

@@ -152,6 +152,9 @@ describe('swapfile detection', function()
it('redrawing during prompt does not break treesitter', function() it('redrawing during prompt does not break treesitter', function()
local testfile = 'Xtest_swapredraw.lua' local testfile = 'Xtest_swapredraw.lua'
finally(function()
os.remove(testfile)
end)
write_file( write_file(
testfile, testfile,
[[ [[
@@ -589,7 +592,9 @@ describe('quitting swapfile dialog on startup stops TUI properly', function()
retry(nil, nil, function() retry(nil, nil, function()
eq( eq(
{ '[Process exited 1]' }, { '[Process exited 1]' },
eval("[1, 2, '$']->map({_, lnum -> getline(lnum)->trim(' ', 2)})->filter({_, s -> !empty(trim(s))})") eval(
"[1, 2, '$']->map({_, lnum -> getline(lnum)->trim(' ', 2)})->filter({_, s -> !empty(trim(s))})"
)
) )
end) end)
end) end)