summaryrefslogtreecommitdiff
path: root/test/command_callback/test_cs_mcsc_command_callbacks.vader
blob: b513b6557a0f784fab5362ef67d5bd9fa6253d15 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
Before:
  Save g:ale_cs_mcsc_options
  Save g:ale_cs_mcsc_source
  Save g:ale_cs_mcsc_assembly_path
  Save g:ale_cs_mcsc_assemblies

  unlet! g:ale_cs_mcsc_options
  unlet! g:ale_cs_mcsc_source
  unlet! g:ale_cs_mcsc_assembly_path
  unlet! g:ale_cs_mcsc_assemblies

  let g:temppath = fnamemodify(tempname(), ':p:h')
  let g:temppathpattern = substitute(escape(g:temppath, '\\/.*$^~[]'), '[\\/]*$', '[\\\\/]\\+\\S\\+','')
  let g:sometempfile = fnamemodify(g:temppath .'/some_temp_file.tmp', ':p')

  runtime ale_linters/cs/mcsc.vim

After:
  Restore
  unlet! b:ale_cs_mcsc_options
  unlet! g:ale_cs_mcsc_source
  unlet! g:ale_cs_mcsc_assembly_path
  unlet! g:ale_cs_mcsc_assemblies
  unlet! g:temppath
  unlet! g:temppathpattern
  unlet! g:sometempfile
  call ale#linter#Reset()

Execute(Check for proper default command):

  let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
  let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
  let b:command = substitute(b:command, '\s\+', ' ', 'g')

  AssertEqual
  \   b:command,
  \   'cd ".";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'

Execute(The options should be be used in the command):

  let g:ale_cs_mcsc_options = '-pkg:dotnet'

  let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
  let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
  let b:command = substitute(b:command, '\s\+', ' ', 'g')

  AssertEqual
  \   b:command,
  \   'cd ".";mcs -unsafe ' . g:ale_cs_mcsc_options . ' -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'

Execute(The souce path should be be used in the command):
  call ale#engine#Cleanup(bufnr(''))
  call ale#engine#InitBufferInfo(bufnr(''))

  let g:ale_cs_mcsc_source='../foo/bar'

  let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
  let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
  let b:command = substitute(b:command, '\s\+', ' ', 'g')

  AssertEqual
  \   b:command,
  \   'cd "' . g:ale_cs_mcsc_source . '";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'

Execute(The list of search pathes for assemblies should be be used in the command if not empty):
  call ale#engine#Cleanup(bufnr(''))
  call ale#engine#InitBufferInfo(bufnr(''))

  let g:ale_cs_mcsc_assembly_path = [
  \ '/usr/lib/mono',
  \ '../foo/bar'
  \]

  let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
  let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
  let b:command = substitute(b:command, '\s\+', ' ', 'g')

  AssertEqual
  \   b:command,
  \   'cd ".";mcs -unsafe -lib:"' . join(g:ale_cs_mcsc_assembly_path,'","') . '" -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'

  let g:ale_cs_mcsc_assembly_path = [
  \]

  let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
  let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
  let b:command = substitute(b:command, '\s\+', ' ', 'g')

  AssertEqual
  \   b:command,
  \   'cd ".";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'

Execute(The list of assemblies should be be used in the command if not empty):
  call ale#engine#Cleanup(bufnr(''))
  call ale#engine#InitBufferInfo(bufnr(''))

  let g:ale_cs_mcsc_assemblies = [
  \ 'foo.dll',
  \ 'bar.dll'
  \]

  let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
  let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
  let b:command = substitute(b:command,'\s\+',' ','g')

  AssertEqual
  \   b:command,
  \   'cd ".";mcs -unsafe -r:"' . join(g:ale_cs_mcsc_assemblies,'","') . '" -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'

  let g:ale_cs_mcsc_assemblies = [
  \]

  let b:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
  let b:command = substitute(b:command, '-out:' . g:temppathpattern, '-out:' . g:sometempfile, '')
  let b:command = substitute(b:command,'\s\+',' ','g')

  AssertEqual
  \   b:command,
  \   'cd ".";mcs -unsafe -out:' . g:sometempfile . ' -t:module -recurse:"*.cs"'