Refactored cs_completer tests some more
Common server-wait code is in a helper func now.
This commit is contained in:
parent
52fdf2d09f
commit
8fd6296f49
@ -332,7 +332,7 @@ class CsharpCompleter( Completer ):
|
||||
""" Check if our OmniSharp server is ready """
|
||||
try:
|
||||
return bool( self._omnisharp_port and
|
||||
self._GetResponse( '/checkreadystatus', silent = True ) )
|
||||
self._GetResponse( '/checkreadystatus', silent = True ) )
|
||||
except:
|
||||
return False
|
||||
|
||||
|
@ -21,7 +21,7 @@ from ..server_utils import SetUpPythonPath
|
||||
SetUpPythonPath()
|
||||
import time
|
||||
from .test_utils import ( Setup, BuildRequest, PathToTestFile,
|
||||
StopOmniSharpServer )
|
||||
StopOmniSharpServer, WaitUntilOmniSharpServerReady )
|
||||
from webtest import TestApp
|
||||
from nose.tools import with_setup, eq_
|
||||
from hamcrest import ( assert_that, contains, contains_string, has_entries,
|
||||
@ -149,16 +149,7 @@ def Diagnostics_CsCompleter_ZeroBasedLineAndColumn_test():
|
||||
event_name = 'FileReadyToParse' )
|
||||
|
||||
results = app.post_json( '/event_notification', event_data )
|
||||
|
||||
# We need to wait until the server has started up.
|
||||
while True:
|
||||
result = app.post_json( '/run_completer_command',
|
||||
BuildRequest( completer_target = 'filetype_default',
|
||||
command_arguments = ['ServerReady'],
|
||||
filetype = 'cs' ) ).json
|
||||
if result:
|
||||
break
|
||||
time.sleep( 0.2 )
|
||||
WaitUntilOmniSharpServerReady( app )
|
||||
|
||||
event_data = BuildRequest( filepath = filepath,
|
||||
event_name = 'FileReadyToParse',
|
||||
@ -230,17 +221,7 @@ def GetDetailedDiagnostic_CsCompleter_Works_test():
|
||||
event_name = 'FileReadyToParse' )
|
||||
|
||||
app.post_json( '/event_notification', event_data )
|
||||
|
||||
# We need to wait until the server has started up.
|
||||
while True:
|
||||
result = app.post_json( '/run_completer_command',
|
||||
BuildRequest( completer_target = 'filetype_default',
|
||||
command_arguments = ['ServerReady'],
|
||||
filetype = 'cs' ) ).json
|
||||
if result:
|
||||
break
|
||||
time.sleep( 0.2 )
|
||||
|
||||
WaitUntilOmniSharpServerReady( app )
|
||||
app.post_json( '/event_notification', event_data )
|
||||
|
||||
diag_data = BuildRequest( filepath = filepath,
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
from ..server_utils import SetUpPythonPath
|
||||
SetUpPythonPath()
|
||||
import time
|
||||
import httplib
|
||||
from .test_utils import ( Setup, BuildRequest, PathToTestFile,
|
||||
ChangeSpecificOptions, StopOmniSharpServer )
|
||||
ChangeSpecificOptions, StopOmniSharpServer,
|
||||
WaitUntilOmniSharpServerReady )
|
||||
from webtest import TestApp, AppError
|
||||
from nose.tools import eq_, with_setup
|
||||
from hamcrest import ( assert_that, has_item, has_items, has_entry,
|
||||
@ -68,16 +68,7 @@ def GetCompletions_CsCompleter_Works_test():
|
||||
event_name = 'FileReadyToParse' )
|
||||
|
||||
app.post_json( '/event_notification', event_data )
|
||||
|
||||
# We need to wait until the server has started up.
|
||||
while True:
|
||||
result = app.post_json( '/run_completer_command',
|
||||
BuildRequest( completer_target = 'filetype_default',
|
||||
command_arguments = ['ServerReady'],
|
||||
filetype = 'cs' ) ).json
|
||||
if result:
|
||||
break
|
||||
time.sleep( 0.2 )
|
||||
WaitUntilOmniSharpServerReady( app )
|
||||
|
||||
completion_data = BuildRequest( filepath = filepath,
|
||||
filetype = 'cs',
|
||||
@ -103,25 +94,13 @@ def GetCompletions_CsCompleter_ReloadSolutionWorks_test():
|
||||
event_name = 'FileReadyToParse' )
|
||||
|
||||
app.post_json( '/event_notification', event_data )
|
||||
|
||||
# We need to wait until the server has started up.
|
||||
while True:
|
||||
result = app.post_json( '/run_completer_command',
|
||||
BuildRequest( completer_target = 'filetype_default',
|
||||
command_arguments = ['ServerReady'],
|
||||
filetype = 'cs' ) ).json
|
||||
if result:
|
||||
break
|
||||
time.sleep( 0.2 )
|
||||
|
||||
|
||||
WaitUntilOmniSharpServerReady( app )
|
||||
result = app.post_json( '/run_completer_command',
|
||||
BuildRequest( completer_target = 'filetype_default',
|
||||
command_arguments = ['ReloadSolution'],
|
||||
filetype = 'cs' ) ).json
|
||||
|
||||
eq_(result, True)
|
||||
|
||||
StopOmniSharpServer( app )
|
||||
|
||||
@with_setup( Setup )
|
||||
@ -139,16 +118,7 @@ def GetCompletions_CsCompleter_StartsWithUnambiguousMultipleSolutions_test():
|
||||
# Here the server will raise an exception if it can't start
|
||||
app.post_json( '/event_notification', event_data )
|
||||
|
||||
# Now for some cleanup: wait for the server to start then shut it down
|
||||
while True:
|
||||
result = app.post_json( '/run_completer_command',
|
||||
BuildRequest( completer_target = 'filetype_default',
|
||||
command_arguments = ['ServerRunning'],
|
||||
filetype = 'cs' ) ).json
|
||||
if result:
|
||||
break
|
||||
time.sleep( 0.2 )
|
||||
|
||||
WaitUntilOmniSharpServerReady( app )
|
||||
StopOmniSharpServer( app )
|
||||
|
||||
@with_setup( Setup )
|
||||
@ -173,6 +143,7 @@ def GetCompletions_CsCompleter_DoesntStartWithAmbiguousMultipleSolutions_test():
|
||||
# the test passes if we caught an exception when trying to start it,
|
||||
# so raise one if it managed to start
|
||||
if not exception_caught:
|
||||
WaitUntilOmniSharpServerReady( app )
|
||||
StopOmniSharpServer( app )
|
||||
raise Exception( ('The Omnisharp server started, despite us not being able '
|
||||
'to find a suitable solution file to feed it. Did you '
|
||||
|
@ -18,6 +18,7 @@
|
||||
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import time
|
||||
from .. import handlers
|
||||
from ycm import user_options_store
|
||||
|
||||
@ -80,3 +81,15 @@ def StopOmniSharpServer( app ):
|
||||
BuildRequest( completer_target = 'filetype_default',
|
||||
command_arguments = ['StopServer'],
|
||||
filetype = 'cs' ) )
|
||||
|
||||
def WaitUntilOmniSharpServerReady( app ):
|
||||
while True:
|
||||
result = app.post_json( '/run_completer_command',
|
||||
BuildRequest( completer_target = 'filetype_default',
|
||||
command_arguments = ['ServerReady'],
|
||||
filetype = 'cs' ) ).json
|
||||
if result:
|
||||
break
|
||||
time.sleep( 0.2 )
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user