6
6
call ale#assert#SetUpLinterTest('python', 'ruff')
7
7
8
8
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
9
- let b:command_tail = ' --format text --stdin-filename %s -'
9
+ let b:command_head = ale#Escape('ruff') . ' -q'
10
+ let b:command_tail = ' --format json-lines --stdin-filename %s -'
10
11
11
12
GivenCommandOutput ['ruff 0.0.83']
12
13
@@ -19,93 +20,93 @@ After:
19
20
20
21
Execute(The ruff callbacks should return the correct default values):
21
22
AssertLinterCwd expand('%:p:h')
22
- AssertLinter 'ruff', ale#Escape('ruff') . b:command_tail
23
+ AssertLinter 'ruff', b:command_head . b:command_tail
23
24
24
25
Execute(ruff should run with the file path of buffer in old versions):
25
26
" version `0.0.69` supports liniting input from stdin
26
27
GivenCommandOutput ['ruff 0.0.68']
27
28
28
29
AssertLinterCwd expand('%:p:h')
29
- AssertLinter 'ruff', ale#Escape('ruff') . b:command_tail[:-23] . ' %s'
30
+ AssertLinter 'ruff', b:command_head . b:command_tail[:-23] . ' %s'
30
31
31
32
Execute(ruff should run with the --output-format flag in new versions):
32
33
GivenCommandOutput ['ruff 0.1.0']
33
34
34
35
AssertLinterCwd expand('%:p:h')
35
- AssertLinter 'ruff', ale#Escape('ruff') . ' --output-format text --stdin-filename %s -'
36
+ AssertLinter 'ruff', b:command_head . ' --output-format json-lines --stdin-filename %s -'
36
37
37
38
Execute(ruff should run with the stdin in new enough versions):
38
39
GivenCommandOutput ['ruff 0.0.83']
39
40
40
41
AssertLinterCwd expand('%:p:h')
41
- AssertLinter 'ruff', ale#Escape('ruff') . b:command_tail[:-3] . ' -'
42
- " AssertLinter 'ruff', ale#Escape('ruff') . b:command_tail[:-3] . '--format text -'
42
+ AssertLinter 'ruff', b:command_head . b:command_tail[:-3] . ' -'
43
+ " AssertLinter 'ruff', b:command_head . b:command_tail[:-3] . '--format json-lines -'
43
44
44
45
Execute(The option for disabling changing directories should work):
45
46
let g:ale_python_ruff_change_directory = 0
46
47
47
48
AssertLinterCwd ''
48
- AssertLinter 'ruff', ale#Escape('ruff') . b:command_tail
49
+ AssertLinter 'ruff', b:command_head . b:command_tail
49
50
50
51
Execute(The ruff executable should be configurable, and escaped properly):
51
52
let g:ale_python_ruff_executable = 'executable with spaces'
52
53
53
- AssertLinter 'executable with spaces', ale#Escape('executable with spaces') . b:command_tail
54
+ AssertLinter 'executable with spaces', ale#Escape('executable with spaces') . ' -q' . b:command_tail
54
55
55
56
Execute(The ruff command callback should let you set options):
56
57
let g:ale_python_ruff_options = '--some-flag'
57
- AssertLinter 'ruff', ale#Escape('ruff') . ' --some-flag' . b:command_tail
58
+ AssertLinter 'ruff', b:command_head . ' --some-flag' . b:command_tail
58
59
59
60
let g:ale_python_ruff_options = '--some-option value'
60
- AssertLinter 'ruff', ale#Escape('ruff') . ' --some-option value' . b:command_tail
61
+ AssertLinter 'ruff', b:command_head . ' --some-option value' . b:command_tail
61
62
62
63
Execute(The ruff callbacks shouldn't detect virtualenv directories where they don't exist):
63
64
call ale#test#SetFilename('../test-files/python/no_virtualenv/subdir/foo/bar.py')
64
65
65
66
AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/no_virtualenv/subdir')
66
- AssertLinter 'ruff', ale#Escape('ruff') . b:command_tail
67
+ AssertLinter 'ruff', b:command_head . b:command_tail
67
68
68
69
Execute(The ruff callbacks should detect virtualenv directories):
69
70
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
70
71
let b:executable = ale#path#Simplify(
71
72
\ g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff'
72
73
\)
73
74
AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir')
74
- AssertLinter b:executable, ale#Escape(b:executable) . b:command_tail
75
+ AssertLinter b:executable, ale#Escape(b:executable) . ' -q' . b:command_tail
75
76
76
77
Execute(You should able able to use the global ruff instead):
77
78
call ale#test#SetFilename('../test-files/python/with_virtualenv/subdir/foo/bar.py')
78
79
let g:ale_python_ruff_use_global = 1
79
80
80
81
AssertLinterCwd ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir')
81
- AssertLinter 'ruff', ale#Escape('ruff') . b:command_tail
82
+ AssertLinter 'ruff', b:command_head . b:command_tail
82
83
83
84
Execute(Setting executable to 'pipenv' appends 'run ruff'):
84
85
let g:ale_python_ruff_executable = 'path/to/pipenv'
85
86
let g:ale_python_ruff_use_global = 1
86
87
87
- AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run ruff'
88
+ AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run ruff -q '
88
89
\ . b:command_tail
89
90
90
91
Execute(Pipenv is detected when python_ruff_auto_pipenv is set):
91
92
let g:ale_python_ruff_auto_pipenv = 1
92
93
call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
93
94
94
95
AssertLinterCwd expand('%:p:h')
95
- AssertLinter 'pipenv', ale#Escape('pipenv') . ' run ruff'
96
+ AssertLinter 'pipenv', ale#Escape('pipenv') . ' run ruff -q '
96
97
\ . b:command_tail
97
98
98
99
Execute(Setting executable to 'poetry' appends 'run ruff'):
99
100
let g:ale_python_ruff_executable = 'path/to/poetry'
100
101
let g:ale_python_ruff_use_global = 1
101
102
102
- AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run ruff'
103
+ AssertLinter 'path/to/poetry', ale#Escape('path/to/poetry') . ' run ruff -q '
103
104
\ . b:command_tail
104
105
105
106
Execute(poetry is detected when python_ruff_auto_poetry is set):
106
107
let g:ale_python_ruff_auto_poetry = 1
107
108
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
108
109
109
110
AssertLinterCwd expand('%:p:h')
110
- AssertLinter 'poetry', ale#Escape('poetry') . ' run ruff'
111
+ AssertLinter 'poetry', ale#Escape('poetry') . ' run ruff -q '
111
112
\ . b:command_tail
0 commit comments