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

Code before:
    )
    matches(
      "E475: Invalid argument: 'term' must be Boolean",
      pcall_err(command, "call jobstart(['cat', '-'], { 'term': 1 })")
    )
    command('set modified')
    matches(
      vim.pesc('jobstart(...,{term=true}) requires unmodified buffer'),
      pcall_err(command, "call jobstart(['cat', '-'], { 'term': v:true })")
    )

    -- Non-failure cases:
    command('set nomodified')
    command("call jobstart(['cat', '-'], { 'term': v:true })")
    command("call jobstart(['cat', '-'], { 'term': v:false })")
  end)

  it('jobstart(term=true) accepts width/height (#33904)', function()
    local buf = api.nvim_create_buf(false, true)
    exec_lua(function()
      vim.api.nvim_buf_call(buf, function()
        vim.fn.jobstart({
          vim.v.progpath,
          '--clean',
          '--headless',
          '+lua print(vim.uv.new_tty(0, true):get_winsize())',
        }, {
          term = true,
          width = 11,
          height = 12,
          env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
        })
      end)
    end)
    retry(nil, nil, function()
      eq({ '11 12' }, api.nvim_buf_get_lines(buf, 0, 1, false))
    end)
  end)

  it('must specify env option as a dict', function()
    command('let g:job_opts.env = v:true')
    local _, err = pcall(function()
      if is_os('win') then
        command("let j = jobstart('set', g:job_opts)")
      else
        command("let j = jobstart('env', g:job_opts)")
      end
    end)
    matches('E475: Invalid argument: env', err)
  end)


Review comment (bug):
this is failing on Windows CI. maybe try 1 instead of 0, idk. `new_tty` is not used in any of our tests. could some other mechanism be used?

```
FAILED test/functional/core/job_spec.lua @ 100: jobs jobstart(term=true) accepts width/height (#33904) test/functional\core\job_spec.lua:117: retry() attempts: 324 test/functional\core\job_spec.lua:118: Expected objects to be the same. Passed in: (table: 0x027ef06a8588) { *[1] = 'nil EBADF: ' } Expected: (table: 0x027ef06ad650) { *[1] = '11 12' } stack traceback: test\testutil.lua:89: in function 'retry' test/functional\core\job_spec.lua:117: in function <test/functional\core\job_spec.lua:100>
```

Code after:
    )
    matches(
      "E475: Invalid argument: 'term' must be Boolean",
      pcall_err(command, "call jobstart(['cat', '-'], { 'term': 1 })")
    )
    command('set modified')
    matches(
      vim.pesc('jobstart(...,{term=true}) requires unmodified buffer'),
      pcall_err(command, "call jobstart(['cat', '-'], { 'term': v:true })")
    )

    -- Non-failure cases:
    command('set nomodified')
    command("call jobstart(['cat', '-'], { 'term': v:true })")
    command("call jobstart(['cat', '-'], { 'term': v:false })")
  end)

  it('jobstart(term=true) accepts width/height (#33904)', function()
    local buf = api.nvim_create_buf(false, true)
    exec_lua(function()
      vim.api.nvim_buf_call(buf, function()
        vim.fn.jobstart({
          vim.v.progpath,
          '--clean',
          '--headless',
          '+lua print(vim.uv.new_tty(1, false):get_winsize())',
        }, {
          term = true,
          width = 11,
          height = 12,
          env = { VIMRUNTIME = os.getenv('VIMRUNTIME') },
        })
      end)
    end)
    retry(nil, nil, function()
      eq({ '11 12' }, api.nvim_buf_get_lines(buf, 0, 1, false))
    end)
  end)

  it('must specify env option as a dict', function()
    command('let g:job_opts.env = v:true')
    local _, err = pcall(function()
      if is_os('win') then
        command("let j = jobstart('set', g:job_opts)")
      else
        command("let j = jobstart('env', g:job_opts)")
      end
    end)
    matches('E475: Invalid argument: env', err)
  end)