fix(zip): missed "password:" prompt if output trails it #41364

Problem:
Flaky test:

    RUN      T1158 nvim.zip reports an incorrect archive password: 11092.84 ms FAIL

The prompt is detected only if the pty output *ends* with "password: ",
but a read may return the prompt plus following bytes.

Solution:
- Match anywhere in the output since the last password was sent. The
  buffer is cleared before each send, so won't match stale text.
- Assert on the reported message, so a failure shows what was reported.
This commit is contained in:
Justin M. Keyes
2026-08-18 06:23:59 -04:00
committed by GitHub
parent d9b4fb1273
commit c5ea9ca2ad
2 changed files with 9 additions and 7 deletions

View File

@@ -198,8 +198,8 @@ local function extract_with_password(command, source, path, dir)
local function wanted()
return exited ~= nil
or buffered:find('password: $') ~= nil
or buffered:find('reenter: $') ~= nil
or buffered:find('password: ', 1, true) ~= nil
or buffered:find('reenter: ', 1, true) ~= nil
end
local reenter = false

View File

@@ -447,14 +447,16 @@ describe('nvim.zip', function()
local reported = exec_lua(function(uri)
vim.api.nvim_input('no1<CR>no2<CR>no3<CR>')
vim.api.nvim_cmd({ cmd = 'edit', args = { uri }, magic = { file = false, bar = false } }, {})
return vim.wait(1000, function()
return vim.api
.nvim_exec2('messages', { output = true }).output
:find('incorrect password', 1, true) ~= nil
local function messages()
return vim.api.nvim_exec2('messages', { output = true }).output
end
vim.wait(1000, function()
return messages():find('zip: ', 1, true) ~= nil
end)
return messages()
end, ('zip://%s/secret.txt'):format(archive))
eq(true, reported)
t.matches('incorrect password', reported)
end)
describe('extract', function()