097_glob_path_spec.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. -- vim: set foldmethod=marker foldmarker=[[,]] :
  2. -- Test whether glob()/globpath() return correct results with certain escaped
  3. -- characters.
  4. local t = require('test.testutil')
  5. local n = require('test.functional.testnvim')()
  6. local clear = n.clear
  7. local command, expect = n.command, n.expect
  8. describe('glob() and globpath()', function()
  9. setup(clear)
  10. setup(function()
  11. if t.is_os('win') then
  12. os.execute('md sautest\\autoload')
  13. os.execute('.>sautest\\autoload\\Test104.vim 2>nul')
  14. os.execute('.>sautest\\autoload\\footest.vim 2>nul')
  15. else
  16. os.execute('mkdir -p sautest/autoload')
  17. os.execute('touch sautest/autoload/Test104.vim')
  18. os.execute('touch sautest/autoload/footest.vim')
  19. end
  20. end)
  21. it('is working', function()
  22. -- Make sure glob() doesn't use the shell
  23. command('set shell=doesnotexist')
  24. -- Consistent sorting of file names
  25. command('set nofileignorecase')
  26. if t.is_os('win') then
  27. command([[$put =glob('Xxx{')]])
  28. command([[$put =glob('Xxx$')]])
  29. command('silent w! Xxx{')
  30. command([[w! Xxx$]])
  31. command([[$put =glob('Xxx{')]])
  32. command([[$put =glob('Xxx$')]])
  33. command([[$put =string(globpath('sautest\autoload', '*.vim'))]])
  34. command([[$put =string(globpath('sautest\autoload', '*.vim', 0, 1))]])
  35. expect([=[
  36. Xxx{
  37. Xxx$
  38. 'sautest\autoload\Test104.vim
  39. sautest\autoload\footest.vim'
  40. ['sautest\autoload\Test104.vim', 'sautest\autoload\footest.vim']]=])
  41. else
  42. command([[$put =glob('Xxx\{')]])
  43. command([[$put =glob('Xxx\$')]])
  44. command('silent w! Xxx\\{')
  45. command([[w! Xxx\$]])
  46. command([[$put =glob('Xxx\{')]])
  47. command([[$put =glob('Xxx\$')]])
  48. command("$put =string(globpath('sautest/autoload', '*.vim'))")
  49. command("$put =string(globpath('sautest/autoload', '*.vim', 0, 1))")
  50. expect([=[
  51. Xxx{
  52. Xxx$
  53. 'sautest/autoload/Test104.vim
  54. sautest/autoload/footest.vim'
  55. ['sautest/autoload/Test104.vim', 'sautest/autoload/footest.vim']]=])
  56. end
  57. end)
  58. teardown(function()
  59. if t.is_os('win') then
  60. os.execute('del /q/f Xxx{ Xxx$')
  61. os.execute('rd /q /s sautest')
  62. else
  63. os.execute('rm -rf sautest Xxx{ Xxx$')
  64. end
  65. end)
  66. end)