]> git.madduck.net Git - etc/vim.git/blob - test/linter/test_ruff.vader

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

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