autochdir_spec.lua 707 B

1234567891011121314151617181920
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local clear = helpers.clear
  3. local eq = helpers.eq
  4. local getcwd = helpers.funcs.getcwd
  5. describe("'autochdir'", function()
  6. it('given on the shell gets processed properly', function()
  7. local targetdir = 'test/functional/fixtures'
  8. -- By default 'autochdir' is off, thus getcwd() returns the repo root.
  9. clear(targetdir..'/tty-test.c')
  10. local rootdir = getcwd()
  11. local expected = rootdir .. '/' .. targetdir
  12. -- With 'autochdir' on, we should get the directory of tty-test.c.
  13. clear('--cmd', 'set autochdir', targetdir..'/tty-test.c')
  14. eq(helpers.iswin() and expected:gsub('/', '\\') or expected, getcwd())
  15. end)
  16. end)