summaryrefslogtreecommitdiff
path: root/test/test_prepare_command.vader
blob: 75e4c0c6f321581e62279d320b42e3837d9a6174 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Before:
  Save &shell
  Save &shellcmdflag

After:
  Restore

Execute(sh should be used when the shell is fish):
  if !has('win32')
    " Set something else, so we will replace that too.
    let &shellcmdflag = '-f'
    let &shell = 'fish'

    AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')

    let &shell = '/usr/bin/fish'

    AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')

    let &shell = '/usr/local/bin/fish'

    AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')
  endif

Execute(sh should be used when the shell is powershell):
  if !has('win32')
    " Set something else, so we will replace that too.
    let &shellcmdflag = '-f'
    let &shell = 'pwsh'

    AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')

    let &shell = '/usr/bin/pwsh'

    AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')

    let &shell = '/usr/local/bin/pwsh'

    AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')
  endif

Execute(Other shells should be used when set):
  if !has('win32')
    let &shell = '/bin/bash'
    let &shellcmdflag = '-c'

    AssertEqual ['/bin/bash', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')
  endif

Execute(cmd /s/c as a string should be used on Windows):
  if has('win32')
    let &shell = 'who cares'
    let &shellcmdflag = 'whatever'

    AssertEqual 'cmd /s/c "foobar"', ale#job#PrepareCommand(bufnr(''), 'foobar')
  endif