Repository: neovim/neovim
File: test/functional/core/job_spec.lua (Lua)

Code before:
      filename,
    })
    -- Wait for startup to complete, so that all terminal responses are received.
    screen:expect([[
      ^                                                  |
      ~                                                 |*3
      {2:[No Name]                       0,0-1          All}|
                                                        |
      {5:-- TERMINAL --}                                    |
    ]])

    feed(':q<CR>')
    if is_os('freebsd') then
      screen:expect { any = vim.pesc('[Process exited 0]') }
    else
      screen:expect([[
                                                          |
        [Process exited 0]^                                |
                                                          |*4
        {5:-- TERMINAL --}                                    |
      ]])
    end
  end)

  it('uses real pipes for stdin/stdout #35984', function()
    skip(is_os('win'), 'Not applicable for Windows')
    -- this fails on linux if we used socketpair() for stdin and stdout,
    -- which libuv does if you ask to create stdio streams for you
    local val = exec_lua([[
      local outpurt
      local job = vim.fn.jobstart('wc /dev/stdin > /dev/stdout', {
      stdout_buffered=true,
      on_stdout=function(chan, data, name)
        output = data
      end})
      vim.fn.chansend(job, 'foo\nbar baz\n')
      vim.fn.chanclose(job, 'stdin')
      vim.fn.jobwait({job})
      return output
      ]])
    eq(2, #val, val)
    eq({ '2', '3', '12', '/dev/stdin' }, vim.split(val[1], '%s+', { trimempty = true }))
    eq('', val[2])
  end)
end)

describe('pty process teardown', function()
  local screen
  before_each(function()
    clear()
    screen = Screen.new(30, 6)

Review comment (suggestion):
if it's not applicable I would suggest early `return`, since otherwise it just adds noise to the "SKIPPED" list

Code after:
      eq({ 'notification', 'exit', { 0, 42 } }, msg)
    end)

    it('jobstart() does not keep ptmx file descriptor open', function()
      -- Start another job (using libuv)
      command('let g:job_opts.pty = 0')
      local other_jobid = eval("jobstart(['cat', '-'], g:job_opts)")
      local other_pid = eval('jobpid(' .. other_jobid .. ')')

      -- Other job doesn't block first job from receiving SIGHUP on jobclose()
      command('call jobclose(j)')
      -- Have to wait so that the SIGHUP can be processed by tty-test on time.
      -- Can't wait for the next message in case this test fails, if it fails
      -- there won't be any more messages, and the test would hang.
      vim.uv.sleep(100)
      local err = exc_exec('call jobpid(j)')
      eq('Vim(call):E900: Invalid channel id', err)

      -- cleanup
      eq(other_pid, eval('jobpid(' .. other_jobid .. ')'))
      command('call jobstop(' .. other_jobid .. ')')
    end)
  end)

  it('does not close the same handle twice on exit #25086', function()
    local filename = string.format('%s.lua', t.tmpname())
    write_file(
      filename,
      [[
      vim.api.nvim_create_autocmd('VimLeavePre', {
        callback = function()
          local id = vim.fn.jobstart('sleep 0')
          vim.fn.jobwait({id})
        end,
      })
    ]]
    )

    local screen = tt.setup_child_nvim({
      '--cmd',
      'set notermguicolors',
      '-i',
      'NONE',
      '-u',
      filename,
    })
    -- Wait for startup to complete, so that all terminal responses are received.
    screen:expect([[
      ^                                                  |
      ~                                                 |*3
      {2:[No Name]                       0,0-1          All}|