neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

ls_spec.lua (1974B)


      1 local t = require('test.testutil')
      2 local n = require('test.functional.testnvim')()
      3 
      4 local clear = n.clear
      5 local command = n.command
      6 local eq = t.eq
      7 local eval = n.eval
      8 local feed = n.feed
      9 local api = n.api
     10 local testprg = n.testprg
     11 local retry = t.retry
     12 
     13 describe(':ls', function()
     14  before_each(function()
     15    clear()
     16  end)
     17 
     18  --- @param start_running_term fun()
     19  --- @param start_finished_term fun()
     20  local function test_ls_terminal_buffer(start_running_term, start_finished_term)
     21    command('edit foo')
     22    command('set hidden')
     23    start_running_term()
     24    command('vsplit')
     25    start_finished_term()
     26 
     27    retry(nil, 5000, function()
     28      local ls_output = eval('execute("ls")')
     29      -- Normal buffer.
     30      eq('\n  1  h ', string.match(ls_output, '\n *1....'))
     31      -- Terminal buffer [R]unning.
     32      eq('\n  2 #aR', string.match(ls_output, '\n *2....'))
     33      -- Terminal buffer [F]inished.
     34      eq('\n  3 %aF', string.match(ls_output, '\n *3....'))
     35    end)
     36 
     37    retry(nil, 5000, function()
     38      local ls_output = eval('execute("ls R")')
     39      -- Just the [R]unning terminal buffer.
     40      eq('\n  2 #aR ', string.match(ls_output, '^\n *2 ... '))
     41    end)
     42 
     43    retry(nil, 5000, function()
     44      local ls_output = eval('execute("ls F")')
     45      -- Just the [F]inished terminal buffer.
     46      eq('\n  3 %aF ', string.match(ls_output, '^\n *3 ... '))
     47    end)
     48  end
     49 
     50  describe('R, F for', function()
     51    it('terminal buffers', function()
     52      api.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
     53      test_ls_terminal_buffer(function()
     54        command('terminal')
     55      end, function()
     56        command('terminal')
     57        feed('iexit<cr>')
     58      end)
     59    end)
     60 
     61    it('nvim_open_term() buffers', function()
     62      test_ls_terminal_buffer(function()
     63        command('enew | call nvim_open_term(0, {})')
     64      end, function()
     65        command('enew | call chanclose(nvim_open_term(0, {}))')
     66      end)
     67    end)
     68  end)
     69 end)