robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #40865 from justinmk/fixcif907614088

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