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
