]> git.madduck.net Git - etc/vim.git/blob - .vim/bundle/ale/test/fixers/test_ruff_fixer_callback.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:

Merge commit '56df844d3c39ec494dacc69eae34272b27db185a' as '.vim/bundle/asyncomplete'
[etc/vim.git] / .vim / bundle / ale / test / fixers / test_ruff_fixer_callback.vader
1 Before:
2   call ale#assert#SetUpFixerTest('python', 'ruff')
3
4   let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
5
6 After:
7   call ale#assert#TearDownFixerTest()
8
9   unlet! g:dir
10   unlet! b:bin_dir
11
12 Execute(The ruff callback should return the correct default values):
13   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
14
15   silent execute 'file ' . fnameescape(file_path)
16
17   let fname = ale#Escape(ale#path#Simplify(file_path))
18
19   " --fix does not support stdin until 0.0.72
20   GivenCommandOutput ['ruff 0.0.72']
21   AssertFixer
22   \ {
23   \   'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
24   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff')) . ' --stdin-filename ' . fname  . ' --fix -',
25   \ }
26
27 Execute(The ruff callback should not use stdin for older versions (< 0.0.72)):
28   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
29
30   silent execute 'file ' . fnameescape(file_path)
31
32   let fname = ale#Escape(ale#path#Simplify(file_path))
33
34   " --fix does not support stdin until 0.0.72
35   GivenCommandOutput ['ruff 0.0.71']
36   AssertFixer
37   \ {
38   \   'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
39   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff')) . ' --stdin-filename ' . fname . ' --fix %s',
40   \ }
41
42 Execute(The ruff callback should not change directory if the option is set to 0):
43   let g:ale_python_ruff_change_directory = 0
44
45   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
46
47   silent execute 'file ' . fnameescape(file_path)
48
49   let fname = ale#Escape(ale#path#Simplify(file_path))
50
51   " --fix does not support stdin until 0.0.72
52   GivenCommandOutput ['ruff 0.0.72']
53   AssertFixer
54   \ {
55   \   'cwd': '%s:h',
56   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff')) . ' --stdin-filename ' . fname . ' --fix -',
57   \ }
58
59 Execute(The ruff callback should respect custom options):
60   let g:ale_python_ruff_options = '--ignore F401 -q'
61
62   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
63
64   silent execute 'file ' . fnameescape(file_path)
65
66   let fname = ale#Escape(ale#path#Simplify(file_path))
67
68   GivenCommandOutput ['ruff 0.0.72']
69   AssertFixer
70   \ {
71   \   'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
72   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff'))
73   \     . ' --ignore F401 -q --stdin-filename '. fname . ' --fix -',
74   \ }
75
76 Execute(The ruff callback should use ruff check for 0.5.0):
77   let file_path = g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py'
78
79   silent execute 'file ' . fnameescape(file_path)
80
81   let fname = ale#Escape(ale#path#Simplify(file_path))
82
83   GivenCommandOutput ['ruff 0.5.0']
84   AssertFixer
85   \ {
86   \   'cwd': ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/subdir'),
87   \   'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/ruff')) . ' check --stdin-filename ' . fname  . ' --fix -',
88   \ }
89
90 Execute(Pipenv is detected when python_ruff_auto_pipenv is set):
91   let g:ale_python_ruff_auto_pipenv = 1
92   let g:ale_python_ruff_change_directory = 0
93
94   let file_path = '../test-files/python/pipenv/whatever.py'
95
96   call ale#test#SetFilename(file_path)
97
98   let fname = ale#Escape(ale#path#Simplify(g:dir . '/'. file_path))
99
100   GivenCommandOutput ['ruff 0.0.72']
101   AssertFixer
102   \ {
103   \   'cwd': '%s:h',
104   \   'command': ale#Escape('pipenv') . ' run ruff --stdin-filename ' . fname . ' --fix -'
105   \ }
106
107 Execute(Poetry is detected when python_ruff_auto_poetry is set):
108   let g:ale_python_ruff_auto_poetry = 1
109   let g:ale_python_ruff_change_directory = 0
110
111   call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
112
113   let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/poetry/whatever.py'))
114
115   GivenCommandOutput ['ruff 0.0.72']
116   AssertFixer
117   \ {
118   \   'cwd': '%s:h',
119   \   'command': ale#Escape('poetry') . ' run ruff --stdin-filename ' . fname . ' --fix -'
120   \ }
121
122 Execute(Poetry is detected when python_ruff_auto_poetry is set, and cwd respects change_directory option):
123   let g:ale_python_ruff_auto_poetry = 1
124   let g:ale_python_ruff_change_directory = 1
125
126   call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
127
128   let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/poetry/whatever.py'))
129
130   GivenCommandOutput ['ruff 0.0.72']
131   AssertFixer
132   \ {
133   \   'cwd': ale#path#Simplify(g:dir . '/../test-files/python/poetry'),
134   \   'command': ale#Escape('poetry') . ' run ruff --stdin-filename ' . fname . ' --fix -'
135   \ }
136
137 Execute(uv is detected when python_ruff_auto_uv is set):
138   let g:ale_python_ruff_auto_uv = 1
139   let g:ale_python_ruff_change_directory = 0
140
141   call ale#test#SetFilename('../test-files/python/uv/whatever.py')
142
143   let fname = ale#Escape(ale#path#Simplify(g:dir .'/../test-files/python/uv/whatever.py'))
144
145   GivenCommandOutput ['ruff 0.0.72']
146   AssertFixer
147   \ {
148   \   'cwd': '%s:h',
149   \   'command': ale#Escape('uv') . ' run ruff --stdin-filename ' . fname . ' --fix -'
150   \ }