File: 01-allow-tests-to-be-run.patch

package info (click to toggle)
vim-youcompleteme 0%2B20240827%2Bgitb6e8c64%2Bds-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,468 kB
  • sloc: python: 10,914; sh: 204; cpp: 141; makefile: 26; f90: 5; xml: 1
file content (417 lines) | stat: -rw-r--r-- 14,413 bytes parent folder | download | duplicates (3)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
Description: Use Debian's ycmd package locations for ycmd in tests
 We neither have the third_party directory for vim-youcompleteme nor
 for ycmd, so we can't import them and we don't want to either.
 .
 The two python tests are removed as we have always Python installed
 in Debian due to dependencies and the tests can for some reason not
 override this properly.
Author: David Kalnischkies <donkult@debian.org>
Forwarded: not-needed

--- a/run_tests.py
+++ b/run_tests.py
@@ -8,20 +8,9 @@
 import sys
 
 DIR_OF_THIS_SCRIPT = p.dirname( p.abspath( __file__ ) )
-DIR_OF_THIRD_PARTY = p.join( DIR_OF_THIS_SCRIPT, 'third_party' )
 
-# We don't include python-future (not to be confused with pythonfutures) because
-# it needs to be inserted in sys.path AFTER the standard library imports but we
-# can't do that with PYTHONPATH because the std lib paths are always appended to
-# PYTHONPATH. We do it correctly inside Vim because we have access to the right
-# sys.path. So for dev, we rely on python-future being installed correctly with
-#
-#   pip install -r python/test_requirements.txt
-#
-# Pip knows how to install this correctly so that it doesn't matter where in
-# sys.path the path is.
 python_path = [ p.join( DIR_OF_THIS_SCRIPT, 'python' ),
-                p.join( DIR_OF_THIRD_PARTY, 'ycmd' ) ]
+                '/usr/lib/ycmd' ]
 if os.environ.get( 'PYTHONPATH' ):
   python_path.append( os.environ[ 'PYTHONPATH' ] )
 os.environ[ 'PYTHONPATH' ] = os.pathsep.join( python_path )
--- a/python/ycm/tests/youcompleteme_test.py
+++ b/python/ycm/tests/youcompleteme_test.py
@@ -34,7 +34,6 @@
 from unittest.mock import call, MagicMock, patch
 from unittest import TestCase
 
-from ycm.paths import _PathToPythonUsedDuringBuild
 from ycm.vimsupport import SetVariableValue
 from ycm.tests import ( StopServer,
                         test_utils,
@@ -226,65 +225,6 @@
     assert_that( 'ycm_core', is_not( is_in( sys.modules ) ) )
 
 
-  @patch( 'ycm.vimsupport.PostVimMessage' )
-  def test_YouCompleteMe_InvalidPythonInterpreterPath( self, post_vim_message ):
-    with UserOptions( {
-      'g:ycm_server_python_interpreter': '/invalid/python/path' } ):
-      try:
-        ycm = YouCompleteMe()
-
-        assert_that( ycm.IsServerAlive(), equal_to( False ) )
-        post_vim_message.assert_called_once_with(
-          "Unable to start the ycmd server. "
-          "Path in 'g:ycm_server_python_interpreter' option does not point "
-          "to a valid Python 3.6+. "
-          "Correct the error then restart the server with "
-          "':YcmRestartServer'." )
-
-        post_vim_message.reset_mock()
-
-        SetVariableValue( 'g:ycm_server_python_interpreter',
-                          _PathToPythonUsedDuringBuild() )
-        ycm.RestartServer()
-
-        assert_that( ycm.IsServerAlive(), equal_to( True ) )
-        post_vim_message.assert_called_once_with( 'Restarting ycmd server...' )
-      finally:
-        WaitUntilReady()
-        StopServer( ycm )
-
-
-  @patch( 'ycmd.utils.PathToFirstExistingExecutable', return_value = None )
-  @patch( 'ycm.paths._EndsWithPython', return_value = False )
-  @patch( 'ycm.vimsupport.PostVimMessage' )
-  def test_YouCompleteMe_NoPythonInterpreterFound(
-      self, post_vim_message, *args ):
-    with UserOptions( {} ):
-      try:
-        with patch( 'ycmd.utils.ReadFile', side_effect = IOError ):
-          ycm = YouCompleteMe()
-
-        assert_that( ycm.IsServerAlive(), equal_to( False ) )
-        post_vim_message.assert_called_once_with(
-          "Unable to start the ycmd server. Cannot find Python 3.6+. "
-          "Set the 'g:ycm_server_python_interpreter' option to a Python "
-          "interpreter path. "
-          "Correct the error then restart the server with "
-          "':YcmRestartServer'." )
-
-        post_vim_message.reset_mock()
-
-        SetVariableValue( 'g:ycm_server_python_interpreter',
-                          _PathToPythonUsedDuringBuild() )
-        ycm.RestartServer()
-
-        assert_that( ycm.IsServerAlive(), equal_to( True ) )
-        post_vim_message.assert_called_once_with( 'Restarting ycmd server...' )
-      finally:
-        WaitUntilReady()
-        StopServer( ycm )
-
-
   @YouCompleteMeInstance()
   @patch( 'ycm.vimsupport.PostVimMessage', new_callable = ExtendedMock )
   def test_YouCompleteMe_NotifyUserIfServerCrashed_UnexpectedCore(
--- a/python/ycm/tests/paths_test.py
+++ b/python/ycm/tests/paths_test.py
@@ -14,45 +14,3 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with YouCompleteMe.  If not, see <http://www.gnu.org/licenses/>.
-
-from ycm.tests.test_utils import MockVimModule
-MockVimModule()
-
-from hamcrest import assert_that
-from unittest import TestCase
-from ycm.paths import _EndsWithPython
-
-
-def EndsWithPython_Good( path ):
-  assert_that( _EndsWithPython( path ),
-              f'Path { path } does not end with a Python name.' )
-
-
-def EndsWithPython_Bad( path ):
-  assert_that( not _EndsWithPython( path ),
-              f'Path { path } does end with a Python name.' )
-
-
-class PathTest( TestCase ):
-  def test_EndsWithPython_Python3Paths( self ):
-    for path in [
-      'python3',
-      '/usr/bin/python3.6',
-      '/home/user/.pyenv/shims/python3.6',
-      r'C:\Python36\python.exe'
-    ]:
-      with self.subTest( path = path ):
-        EndsWithPython_Good( path )
-
-
-  def test_EndsWithPython_BadPaths( self ):
-    for path in [
-      None,
-      '',
-      '/opt/local/bin/vim',
-      r'C:\Program Files\Vim\vim74\gvim.exe',
-      '/usr/bin/python2.7',
-      '/home/user/.pyenv/shims/python3.2',
-    ]:
-      with self.subTest( path = path ):
-        EndsWithPython_Bad( path )
--- a/test/completion.common.vim
+++ b/test/completion.common.vim
@@ -2,7 +2,7 @@
 
 function! Test_Compl_After_Trigger()
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/clangd/testdata/basic.cpp', {} )
+        \ '/debian/tests/data/basic.cpp', {} )
 
   call setpos( '.', [ 0, 11, 6 ] )
 
@@ -26,7 +26,7 @@
 
 function! Test_Force_Semantic_TopLevel()
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/clangd/testdata/basic.cpp', {} )
+        \ '/debian/tests/data/basic.cpp', {} )
 
   call setpos( '.', [ 0, 17, 5 ] )
 
@@ -53,7 +53,7 @@
 
 function! Test_Select_Next_Previous()
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/clangd/testdata/basic.cpp', {} )
+        \ '/debian/tests/data/basic.cpp', {} )
 
   call setpos( '.', [ 0, 11, 6 ] )
 
@@ -366,7 +366,7 @@
 
 function! Test_Select_Next_Previous_InsertModeMapping()
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/clangd/testdata/basic.cpp', {} )
+        \ '/debian/tests/data/basic.cpp', {} )
 
   call setpos( '.', [ 0, 11, 6 ] )
 
@@ -446,7 +446,7 @@
 
 function! Test_Manual_Trigger()
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/clangd/testdata/basic.cpp', {} )
+        \ '/debian/tests/data/basic.cpp', {} )
 
   call setpos( '.', [ 0, 11, 6 ] )
 
@@ -494,7 +494,7 @@
 
 function! Test_Manual_Trigger_CompleteFunc()
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/clangd/testdata/basic.cpp', {} )
+        \ '/debian/tests/data/basic.cpp', {} )
 
   call setpos( '.', [ 0, 11, 6 ] )
   set completefunc=youcompleteme#CompleteFunc
--- a/test/completion_info.test.vim
+++ b/test/completion_info.test.vim
@@ -51,11 +51,11 @@
 
 function! Test_ResolveCompletion_OnChange()
   call SkipIf( !exists( '*popup_findinfo' ), 'no popup_findinfo' )
+  call SkipJava()
 
   " Only the java completer actually uses the completion resolve
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/java/testdata/simple_eclipse_project' .
-        \ '/src/com/test/TestWithDocumentation.java', { 'delay': 15 } )
+        \ '/debian/tests/data/TestWithDocumentation.java', { 'delay': 15 } )
 
   call setpos( '.', [ 0, 6, 21 ] )
   " Required to trigger TextChangedI
@@ -116,11 +116,11 @@
 
 function! Test_Resolve_FixIt()
   call SkipIf( !exists( '*popup_findinfo' ), 'no popup_findinfo' )
+  call SkipJava()
 
   " Only the java completer actually uses the completion resolve
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/java/testdata/simple_eclipse_project' .
-        \ '/src/com/test/TestWithDocumentation.java', { 'delay': 15 } )
+        \ '/debian/tests/data/TestWithDocumentation.java', { 'delay': 15 } )
 
   " Required to trigger TextChangedI
   " https://github.com/vim/vim/issues/4665#event-2480928194
@@ -157,11 +157,11 @@
 
 function! Test_DontResolveCompletion_AlreadyResolved()
   call SkipIf( !exists( '*popup_findinfo' ), 'no popup_findinfo' )
+  call SkipJava()
 
   " Only the java completer actually uses the completion resolve
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/java/testdata/simple_eclipse_project' .
-        \ '/src/com/test/TestWithDocumentation.java', { 'delay': 15 } )
+        \ '/debian/tests/data/TestWithDocumentation.java', { 'delay': 15 } )
 
   call setpos( '.', [ 0, 7, 12 ] )
   " Required to trigger TextChangedI
--- a/test/diagnostics.test.vim
+++ b/test/diagnostics.test.vim
@@ -168,9 +168,9 @@
 endfunction
 
 function! Test_MessagePoll_Multiple_Filetypes()
+  call SkipJava()
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/java/testdata/simple_eclipse_project' .
-        \ '/src/com/test/TestLauncher.java', {} )
+        \ '/debian/tests/data/TestLauncher.java', {} )
   call WaitForAssert( {->
       \ assert_true( len( sign_getplaced(
                             \ '%',
--- a/test/fixit.test.vim
+++ b/test/fixit.test.vim
@@ -12,9 +12,9 @@
 endfunction
 
 function! Test_Ranged_Fixit_Works()
+  call SkipJava()
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/java/testdata/simple_eclipse_project' .
-        \ '/src/com/test/TestLauncher.java', { 'delay': 15 } )
+        \ '/debian/tests/data/TestLauncher.java', { 'delay': 15 } )
 
   call setpos( '.', [ 0, 34, 50 ] )
   redraw
--- a/test/signature_help.test.vim
+++ b/test/signature_help.test.vim
@@ -80,7 +80,7 @@
 " This is how we might do screen dump tests
 " function! Test_Compl()
 "   let setup =<< trim END
-"     edit ../third_party/ycmd/ycmd/tests/clangd/testdata/general_fallback/make_drink.cc
+"     edit ../debian/tests/data/make_drink.cc
 "     call setpos( '.', [ 0, 7, 27 ] )
 "   END
 "   call writefile( setup, 'Xtest_Compl' )
@@ -179,8 +179,7 @@
 
 function! Test_Signatures_With_PUM_NoSigns()
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/clangd/testdata/general_fallback'
-        \ . '/make_drink.cc', {} )
+        \ '/debian/tests/data/make_drink.cc', {} )
 
   call s:WaitForSigHelpAvailable( 'cpp' )
 
@@ -255,8 +254,7 @@
 
 function! Test_Signatures_With_PUM_Signs()
   call youcompleteme#test#setup#OpenFile(
-        \ '/third_party/ycmd/ycmd/tests/clangd/testdata/general_fallback'
-        \ . '/make_drink.cc', {} )
+        \ '/debian/tests/data/make_drink.cc', {} )
 
   call s:WaitForSigHelpAvailable( 'cpp' )
 
@@ -789,6 +787,7 @@
 endfunction
 
 function! SetUp_Test_Signature_Help_Manual_HideShow()
+  call youcompleteme#test#setup#PushGlobal( 'ycm_global_ycm_extra_conf', '' )
   imap <silent> kjkj <Plug>(YCMToggleSignatureHelp)
 endfunction
 
@@ -837,9 +836,11 @@
 
 function! TearDown_Test_Signature_Help_Manual_HideShow()
   silent! iunmap kjkj
+  call youcompleteme#test#setup#PopGlobal( 'ycm_global_ycm_extra_conf' )
 endfunction
 
 function! SetUp_Test_Signature_Help_Manual_NoSigs()
+  call youcompleteme#test#setup#PushGlobal( 'ycm_global_ycm_extra_conf', '' )
   imap <silent> kjkj <Plug>(YCMToggleSignatureHelp)
 endfunction
 
@@ -891,4 +892,5 @@
 
 function! TearDown_Test_Signature_Help_Manual_NoSigs()
   silent! iunmap kjkj
+  call youcompleteme#test#setup#PopGlobal( 'ycm_global_ycm_extra_conf' )
 endfunction
--- a/test/lib/plugin/shared.vim
+++ b/test/lib/plugin/shared.vim
@@ -19,7 +19,11 @@
   endif
 endfunction
 
-" Wait for up to five seconds for "expr" to become true.  "expr" can be a
+func SkipJava()
+  throw 'SKIPPED: Java completer not supported in Debian yet'
+endfunction
+
+" Wait for up to ten seconds for "expr" to become true.  "expr" can be a
 " stringified expression to evaluate, or a funcref without arguments.
 " Using a lambda works best.  Example:
 "	call WaitFor({-> status == "ok"})
@@ -30,7 +34,7 @@
 " When running into the timeout an exception is thrown, thus the function does
 " not return.
 func WaitFor(expr, ...)
-  let timeout = get(a:000, 0, 5000)
+  let timeout = get(a:000, 0, 10000)
   let slept = s:WaitForCommon(a:expr, v:null, timeout)
   if slept < 0
     throw 'WaitFor() timed out after ' . timeout . ' msec'
@@ -38,7 +42,7 @@
   return slept
 endfunc
 
-" Wait for up to five seconds for "assert" to return zero.  "assert" must be a
+" Wait for up to ten seconds for "assert" to return zero.  "assert" must be a
 " (lambda) function containing one assert function.  Example:
 "	call WaitForAssert({-> assert_equal("dead", job_status(job)})
 "
@@ -46,7 +50,7 @@
 "
 " Return zero for success, one for failure (like the assert function).
 func WaitForAssert(assert, ...)
-  let timeout = get(a:000, 0, 5000)
+  let timeout = get(a:000, 0, 10000)
   if s:WaitForCommon(v:null, a:assert, timeout) < 0
     return 1
   endif
--- a/test/run_vim_tests
+++ b/test/run_vim_tests
@@ -41,7 +41,11 @@
   # split on : into fileName and testName
   IFS=: read -s t T <<< "$t"
 
-  TESTLOGDIR=$(pwd)/logs/$t
+  if [ -n "${AUTOPKGTEST_ARTIFACTS}" ]; then
+    TESTLOGDIR="${AUTOPKGTEST_ARTIFACTS}/$t"
+  else
+    TESTLOGDIR="$(pwd)/logs/$t"
+  fi
 
   if ${RUN_TEST} --cmd 'au SwapExists * let v:swapchoice = "e"' $t $T \
      && [ -f $t.res ];  then
--- a/test/vimrc
+++ b/test/vimrc
@@ -12,7 +12,13 @@
   au SwapExists * let v:swapchoice = 'e'
 augroup END
 
-let &runtimepath = g:ycm_test_plugin_dir . ',' . &runtimepath
+if $AUTOPKGTEST_TMP == ''
+  let &runtimepath = g:ycm_test_plugin_dir . ',' . &runtimepath
+elseif $YCM_TEST_VAM == 'yes'
+  let &runtimepath = '~/.vim,' . &runtimepath . ',~/.vim/after'
+else
+  packadd! youcompleteme
+endif
 
 filetype plugin indent on
 syntax enable