path_spec.lua 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. local helpers = require('test.functional.helpers')(after_each)
  2. local clear = helpers.clear
  3. local eq = helpers.eq
  4. local eval = helpers.eval
  5. local command = helpers.command
  6. local iswin = helpers.iswin
  7. describe('path collapse', function()
  8. local targetdir
  9. local expected_path
  10. local function join_path(...)
  11. local pathsep = (iswin() and '\\' or '/')
  12. return table.concat({...}, pathsep)
  13. end
  14. before_each(function()
  15. targetdir = join_path('test', 'functional', 'fixtures')
  16. clear()
  17. command('edit '..join_path(targetdir, 'tty-test.c'))
  18. expected_path = eval('expand("%:p")')
  19. end)
  20. it('with /./ segment #7117', function()
  21. command('edit '..join_path(targetdir, '.', 'tty-test.c'))
  22. eq(expected_path, eval('expand("%:p")'))
  23. end)
  24. it('with ./ prefix #7117', function()
  25. command('edit '..join_path('.', targetdir, 'tty-test.c'))
  26. eq(expected_path, eval('expand("%:p")'))
  27. end)
  28. it('with ./ prefix, after directory change #7117', function()
  29. command('edit '..join_path('.', targetdir, 'tty-test.c'))
  30. command('cd test')
  31. eq(expected_path, eval('expand("%:p")'))
  32. end)
  33. it('with /../ segment #7117', function()
  34. command('edit '..join_path(targetdir, '..', 'fixtures', 'tty-test.c'))
  35. eq(expected_path, eval('expand("%:p")'))
  36. end)
  37. it('with ../ and different starting directory #7117', function()
  38. command('cd test')
  39. command('edit '..join_path('..', targetdir, 'tty-test.c'))
  40. eq(expected_path, eval('expand("%:p")'))
  41. end)
  42. it('with ./../ and different starting directory #7117', function()
  43. command('cd test')
  44. command('edit '..join_path('.', '..', targetdir, 'tty-test.c'))
  45. eq(expected_path, eval('expand("%:p")'))
  46. end)
  47. end)