Making the cs_completer test less flaky

This commit is contained in:
Strahinja Val Markovic 2013-10-09 13:17:53 -07:00
parent aac33b61e9
commit 70a51be209
2 changed files with 16 additions and 4 deletions

View File

@ -72,6 +72,7 @@ class CsharpCompleter( Completer ):
return [ 'StartServer', return [ 'StartServer',
'StopServer', 'StopServer',
'RestartServer', 'RestartServer',
'ServerRunning',
'GoToDefinition', 'GoToDefinition',
'GoToDeclaration', 'GoToDeclaration',
'GoToDefinitionElseDeclaration' ] 'GoToDefinitionElseDeclaration' ]
@ -96,6 +97,8 @@ class CsharpCompleter( Completer ):
if self._ServerIsRunning(): if self._ServerIsRunning():
self._StopServer() self._StopServer()
self._StartServer( request_data ) self._StartServer( request_data )
elif command == 'ServerRunning':
return self._ServerIsRunning()
elif command in [ 'GoToDefinition', elif command in [ 'GoToDefinition',
'GoToDeclaration', 'GoToDeclaration',
'GoToDefinitionElseDeclaration' ]: 'GoToDefinitionElseDeclaration' ]:
@ -198,8 +201,11 @@ class CsharpCompleter( Completer ):
def _ServerIsRunning( self ): def _ServerIsRunning( self ):
""" Check if our OmniSharp server is running """ """ Check if our OmniSharp server is running """
return ( self._omnisharp_port != None and try:
self._GetResponse( '/checkalivestatus', silent = True ) != None ) return bool( self._omnisharp_port and
self._GetResponse( '/checkalivestatus', silent = True ) )
except:
return False
def _ServerLocation( self ): def _ServerLocation( self ):

View File

@ -115,8 +115,14 @@ def GetCompletions_CsCompleter_Works_test():
app.post_json( '/event_notification', event_data ) app.post_json( '/event_notification', event_data )
# We need to wait until the server has started up. # We need to wait until the server has started up.
# TODO: This is a HORRIBLE hack. Fix it! while True:
time.sleep( 2 ) 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 )
completion_data = BuildRequest( filepath = filepath, completion_data = BuildRequest( filepath = filepath,
filetype = 'cs', filetype = 'cs',