097_glob_path_spec.lua 2.3 KB

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