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
@ -21,7 +21,7 @@ from ..server_utils import SetUpPythonPath
|
|||||||
SetUpPythonPath()
|
SetUpPythonPath()
|
||||||
import time
|
import time
|
||||||
from .test_utils import ( Setup, BuildRequest, PathToTestFile,
|
from .test_utils import ( Setup, BuildRequest, PathToTestFile,
|
||||||
StopOmniSharpServer )
|
StopOmniSharpServer, WaitUntilOmniSharpServerReady )
|
||||||
from webtest import TestApp
|
from webtest import TestApp
|
||||||
from nose.tools import with_setup, eq_
|
from nose.tools import with_setup, eq_
|
||||||
from hamcrest import ( assert_that, contains, contains_string, has_entries,
|
from hamcrest import ( assert_that, contains, contains_string, has_entries,
|
||||||
@ -149,16 +149,7 @@ def Diagnostics_CsCompleter_ZeroBasedLineAndColumn_test():
|
|||||||
event_name = 'FileReadyToParse' )
|
event_name = 'FileReadyToParse' )
|
||||||
|
|
||||||
results = app.post_json( '/event_notification', event_data )
|
results = app.post_json( '/event_notification', event_data )
|
||||||
|
WaitUntilOmniSharpServerReady( app )
|
||||||
# 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 )
|
|
||||||
|
|
||||||
event_data = BuildRequest( filepath = filepath,
|
event_data = BuildRequest( filepath = filepath,
|
||||||
event_name = 'FileReadyToParse',
|
event_name = 'FileReadyToParse',
|
||||||
@ -230,17 +221,7 @@ def GetDetailedDiagnostic_CsCompleter_Works_test():
|
|||||||
event_name = 'FileReadyToParse' )
|
event_name = 'FileReadyToParse' )
|
||||||
|
|
||||||
app.post_json( '/event_notification', event_data )
|
app.post_json( '/event_notification', event_data )
|
||||||
|
WaitUntilOmniSharpServerReady( app )
|
||||||
# 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 )
|
|
||||||
|
|
||||||
app.post_json( '/event_notification', event_data )
|
app.post_json( '/event_notification', event_data )
|
||||||
|
|
||||||
diag_data = BuildRequest( filepath = filepath,
|
diag_data = BuildRequest( filepath = filepath,
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
from ..server_utils import SetUpPythonPath
|
from ..server_utils import SetUpPythonPath
|
||||||
SetUpPythonPath()
|
SetUpPythonPath()
|
||||||
import time
|
|
||||||
import httplib
|
import httplib
|
||||||
from .test_utils import ( Setup, BuildRequest, PathToTestFile,
|
from .test_utils import ( Setup, BuildRequest, PathToTestFile,
|
||||||
ChangeSpecificOptions, StopOmniSharpServer )
|
ChangeSpecificOptions, StopOmniSharpServer,
|
||||||
|
WaitUntilOmniSharpServerReady )
|
||||||
from webtest import TestApp, AppError
|
from webtest import TestApp, AppError
|
||||||
from nose.tools import eq_, with_setup
|
from nose.tools import eq_, with_setup
|
||||||
from hamcrest import ( assert_that, has_item, has_items, has_entry,
|
from hamcrest import ( assert_that, has_item, has_items, has_entry,
|
||||||
@ -68,16 +68,7 @@ def GetCompletions_CsCompleter_Works_test():
|
|||||||
event_name = 'FileReadyToParse' )
|
event_name = 'FileReadyToParse' )
|
||||||
|
|
||||||
app.post_json( '/event_notification', event_data )
|
app.post_json( '/event_notification', event_data )
|
||||||
|
WaitUntilOmniSharpServerReady( app )
|
||||||
# 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 )
|
|
||||||
|
|
||||||
completion_data = BuildRequest( filepath = filepath,
|
completion_data = BuildRequest( filepath = filepath,
|
||||||
filetype = 'cs',
|
filetype = 'cs',
|
||||||
@ -103,25 +94,13 @@ def GetCompletions_CsCompleter_ReloadSolutionWorks_test():
|
|||||||
event_name = 'FileReadyToParse' )
|
event_name = 'FileReadyToParse' )
|
||||||
|
|
||||||
app.post_json( '/event_notification', event_data )
|
app.post_json( '/event_notification', event_data )
|
||||||
|
WaitUntilOmniSharpServerReady( app )
|
||||||
# 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 )
|
|
||||||
|
|
||||||
|
|
||||||
result = app.post_json( '/run_completer_command',
|
result = app.post_json( '/run_completer_command',
|
||||||
BuildRequest( completer_target = 'filetype_default',
|
BuildRequest( completer_target = 'filetype_default',
|
||||||
command_arguments = ['ReloadSolution'],
|
command_arguments = ['ReloadSolution'],
|
||||||
filetype = 'cs' ) ).json
|
filetype = 'cs' ) ).json
|
||||||
|
|
||||||
eq_(result, True)
|
eq_(result, True)
|
||||||
|
|
||||||
StopOmniSharpServer( app )
|
StopOmniSharpServer( app )
|
||||||
|
|
||||||
@with_setup( Setup )
|
@with_setup( Setup )
|
||||||
@ -139,16 +118,7 @@ def GetCompletions_CsCompleter_StartsWithUnambiguousMultipleSolutions_test():
|
|||||||
# Here the server will raise an exception if it can't start
|
# Here the server will raise an exception if it can't start
|
||||||
app.post_json( '/event_notification', event_data )
|
app.post_json( '/event_notification', event_data )
|
||||||
|
|
||||||
# Now for some cleanup: wait for the server to start then shut it down
|
WaitUntilOmniSharpServerReady( app )
|
||||||
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 )
|
|
||||||
|
|
||||||
StopOmniSharpServer( app )
|
StopOmniSharpServer( app )
|
||||||
|
|
||||||
@with_setup( Setup )
|
@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,
|
# the test passes if we caught an exception when trying to start it,
|
||||||
# so raise one if it managed to start
|
# so raise one if it managed to start
|
||||||
if not exception_caught:
|
if not exception_caught:
|
||||||
|
WaitUntilOmniSharpServerReady( app )
|
||||||
StopOmniSharpServer( app )
|
StopOmniSharpServer( app )
|
||||||
raise Exception( ('The Omnisharp server started, despite us not being able '
|
raise Exception( ('The Omnisharp server started, despite us not being able '
|
||||||
'to find a suitable solution file to feed it. Did you '
|
'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/>.
|
# along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
from .. import handlers
|
from .. import handlers
|
||||||
from ycm import user_options_store
|
from ycm import user_options_store
|
||||||
|
|
||||||
@ -80,3 +81,15 @@ def StopOmniSharpServer( app ):
|
|||||||
BuildRequest( completer_target = 'filetype_default',
|
BuildRequest( completer_target = 'filetype_default',
|
||||||
command_arguments = ['StopServer'],
|
command_arguments = ['StopServer'],
|
||||||
filetype = 'cs' ) )
|
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