All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 call ale#assert#SetUpLinterTest('php', 'phpstan')
6 " Create a temporary directory and work within it, otherwise these tests
7 " cannot be run in parallel.
8 let g:parent_dir = tempname()
9 let g:dir = ale#path#Simplify(g:parent_dir . '/src')
11 call mkdir(g:parent_dir, '', 0750)
12 call mkdir(g:dir, '', 0750)
14 silent! execute 'cd ' . fnameescape(g:dir)
15 silent! noautocmd execute 'file ' . fnameescape(ale#path#Simplify(g:dir . '/test.php'))
17 call delete('./phpstan.neon')
19 GivenCommandOutput ['0.10.2']
22 silent! execute 'cd ' . fnameescape(g:old_dir)
23 call delete(g:dir, 'rf')
26 call ale#assert#TearDownLinterTest()
28 Execute(The local phpstan executable should be used):
29 call mkdir('vendor/bin', 'p', 0750)
30 call writefile([''], 'vendor/bin/phpstan')
31 call ale#test#SetFilename('phpstan-test-files/foo/test.php')
33 let g:executable = ale#path#Simplify(g:dir . '/vendor/bin/phpstan')
35 AssertLinter g:executable,
36 \ ale#Escape(g:executable) . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('4') . ' %s'
37 AssertLinterCwd v:null
39 Execute(use_global should override local executable detection):
40 let g:ale_php_phpstan_use_global = 1
42 call mkdir('vendor/bin', 'p', 0750)
43 call writefile([''], 'vendor/bin/phpstan')
44 call ale#test#SetFilename('phpstan-test-files/foo/test.php')
46 AssertLinter 'phpstan',
47 \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('4') . ' %s'
49 Execute(Custom executables should be used for the executable and command):
50 let g:ale_php_phpstan_executable = 'phpstan_test'
52 AssertLinter 'phpstan_test',
53 \ ale#Escape('phpstan_test') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('4') . ' %s'
55 Execute(project with level set to 3):
56 call ale#test#SetFilename('phpstan-test-files/foo/test.php')
57 let g:ale_php_phpstan_level = 3
59 AssertLinter 'phpstan',
60 \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('3') . ' %s'
62 Execute(Custom phpstan configuration file):
63 let g:ale_php_phpstan_configuration = 'phpstan_config'
65 AssertLinter 'phpstan',
66 \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -c ' . ale#Escape('phpstan_config') . ' -l ' . ale#Escape('4') . ' %s'
68 Execute(Choose the right format for error format param):
69 GivenCommandOutput ['0.10.3']
71 AssertLinter 'phpstan', [
72 \ ale#Escape('phpstan') . ' --version',
73 \ ale#Escape('phpstan') . ' analyze --no-progress --error-format json -l ' . ale#Escape('4') . ' %s'
76 Execute(Configuration file exists in current directory):
77 call writefile(['parameters:', ' level: 7'], './phpstan.neon')
78 let g:ale_php_phpstan_level = ''
79 let g:ale_php_phpstan_configuration = ''
81 AssertLinter 'phpstan', [
82 \ ale#Escape('phpstan') . ' --version',
83 \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json %s'
87 Execute(Configuration dist file exists in current directory):
88 call writefile(['parameters:', ' level: 7'], './phpstan.neon.dist')
89 let g:ale_php_phpstan_level = ''
90 let g:ale_php_phpstan_configuration = ''
92 AssertLinter 'phpstan', [
93 \ ale#Escape('phpstan') . ' --version',
94 \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json %s'
98 Execute(Configuration file exists in current directory, but force phpstan level):
99 call writefile(['parameters:', ' level: 7'], './phpstan.neon')
100 let g:ale_php_phpstan_configuration = ''
101 let g:ale_php_phpstan_level = '7'
103 AssertLinter 'phpstan', [
104 \ ale#Escape('phpstan') . ' --version',
105 \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('7') . ' %s'
108 Execute(Configuration file exists in current directory, but force phpstan configuration):
109 call writefile(['parameters:', ' level: 7'], './phpstan.neon')
110 let g:ale_php_phpstan_level = ''
111 let g:ale_php_phpstan_configuration = 'phpstan.custom.neon'
113 AssertLinter 'phpstan', [
114 \ ale#Escape('phpstan') . ' --version',
115 \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -c ' . ale#Escape('phpstan.custom.neon') . ' %s'
118 Execute(Autoload parameter is added to the command):
119 let g:ale_php_phpstan_autoload = 'autoload.php'
121 AssertLinter 'phpstan',
122 \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -a ' . ale#Escape('autoload.php') . ' -l ' . ale#Escape('4') . ' %s'
124 Execute(Memory limit parameter is added to the command):
125 let g:ale_php_phpstan_memory_limit = '500M'
127 AssertLinter 'phpstan',
128 \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json -l ' . ale#Escape('4') . ' --memory-limit=' . ale#Escape('500M') . ' %s'
130 Execute(Directory is changed to that of the configuration file):
131 call writefile([], '../phpstan.neon')
133 AssertLinterCwd g:parent_dir
134 AssertLinter 'phpstan',
135 \ ale#Escape('phpstan') . ' analyze --no-progress --errorFormat json %s'