コード例 #1
0
 def Wrapper(*args, **kwargs):
     with IgnoreExtraConfOutsideTestsFolder():
         with IsolatedApp(custom_options) as app:
             try:
                 test(app, *args, **kwargs)
             finally:
                 StopCompleterServer(app, 'foo')
コード例 #2
0
def tearDownPackage():
    """Cleans up the tests using the SharedYcmd decorator in this package. It is
  executed once after running all the tests in the package."""
    global shared_app, shared_current_dir

    StopCompleterServer(shared_app, 'javascript')
    os.chdir(shared_current_dir)
コード例 #3
0
ファイル: __init__.py プロジェクト: pombredanne/ycmd
 def Wrapper(*args, **kwargs):
     with IsolatedApp() as app:
         try:
             with CurrentWorkingDirectory(directory):
                 test(app, *args, **kwargs)
         finally:
             StopCompleterServer(app, 'javascript')
コード例 #4
0
def ServerManagement_StopServer_Killed_test( app ):
  StartClangd( app )
  process = psutil.Process( GetPid( app ) )
  process.terminate()
  process.wait( timeout = 5 )
  StopCompleterServer( app, 'cpp', '' )
  CheckStopped( app )
コード例 #5
0
ファイル: __init__.py プロジェクト: ctomiao2/vim
 def Wrapper(*args, **kwargs):
     with IsolatedApp(custom_options) as app:
         clangd_completer.CLANGD_COMMAND = clangd_completer.NOT_CACHED
         try:
             test(app, *args, **kwargs)
         finally:
             StopCompleterServer(app, 'cpp')
コード例 #6
0
ファイル: subcommands_test.py プロジェクト: sukeyisme/ycmd
def StopServer_KeepLogFiles( app, keeping_log_files ):
  with UserOption( 'server_keep_logfiles', keeping_log_files ):
    filepath = PathToTestFile( 'testy', 'GotoTestCase.cs' )
    contents = ReadFile( filepath )
    event_data = BuildRequest( filepath = filepath,
                               filetype = 'cs',
                               contents = contents,
                               event_name = 'FileReadyToParse' )

    app.post_json( '/event_notification', event_data )
    WaitUntilCompleterServerReady( app, 'cs' )

    event_data = BuildRequest( filetype = 'cs', filepath = filepath )

    response = app.post_json( '/debug_info', event_data ).json

    logfiles = []
    for server in response[ 'completer' ][ 'servers' ]:
      logfiles.extend( server[ 'logfiles' ] )

    try:
      for logfile in logfiles:
        ok_( os.path.exists( logfile ),
             'Logfile should exist at {0}'.format( logfile ) )
    finally:
      StopCompleterServer( app, 'cs', filepath )

    if keeping_log_files:
      for logfile in logfiles:
        ok_( os.path.exists( logfile ),
             'Logfile should still exist at {0}'.format( logfile ) )
    else:
      for logfile in logfiles:
        ok_( not os.path.exists( logfile ),
             'Logfile should no longer exist at {0}'.format( logfile ) )
コード例 #7
0
def set_up_shared_app():
    global shared_app
    shared_app = SetUpApp()
    with IgnoreExtraConfOutsideTestsFolder():
        StartGoCompleterServerInDirectory(shared_app, PathToTestFile())
    yield
    StopCompleterServer(shared_app, 'go')
コード例 #8
0
ファイル: __init__.py プロジェクト: j-carl/ycmd
def tearDownPackage():
    """Cleans up the tests using the SharedYcmd decorator in this package. It is
  executed once after running all the tests in the package."""
    global shared_app, shared_filepaths

    for filepath in shared_filepaths:
        StopCompleterServer(shared_app, 'cs', filepath)
コード例 #9
0
def GetCompletions_ServerIsNotRunning_test( app ):
  StopCompleterServer( app, filetype = 'typescript' )

  filepath = PathToTestFile( 'test.ts' )
  contents = ReadFile( filepath )

  # Check that sending a request to TSServer (the response is ignored) raises
  # the proper exception.
  event_data = BuildRequest( filepath = filepath,
                             filetype = 'typescript',
                             contents = contents,
                             event_name = 'BufferVisit' )

  assert_that(
    calling( app.post_json ).with_args( '/event_notification', event_data ),
    raises( AppError, 'TSServer is not running.' ) )

  # Check that sending a command to TSServer (the response is processed) raises
  # the proper exception.
  completion_data = BuildRequest( filepath = filepath,
                                  filetype = 'typescript',
                                  contents = contents,
                                  force_semantic = True,
                                  line_num = 17,
                                  column_num = 6 )

  assert_that(
    calling( app.post_json ).with_args( '/completions', completion_data ),
    raises( AppError, 'TSServer is not running.' ) )
コード例 #10
0
ファイル: conftest.py プロジェクト: katosun2/YouCompleteMe
def set_up_shared_app():
    global shared_app
    shared_app = SetUpApp()
    with IgnoreExtraConfOutsideTestsFolder():
        StartRustCompleterServerInDirectory(shared_app,
                                            PathToTestFile('common', 'src'))
    yield
    StopCompleterServer(shared_app, 'rust')
コード例 #11
0
 def Wrapper( *args, **kwargs ):
   old_server_state = handlers._server_state
   app = SetUpApp()
   try:
     test( app, *args, **kwargs )
   finally:
     StopCompleterServer( app, 'typescript' )
     handlers._server_state = old_server_state
コード例 #12
0
ファイル: __init__.py プロジェクト: rootmass/dotfiles
 def Wrapper(*args, **kwargs):
     old_server_state = handlers._server_state
     app = SetUpApp(custom_options)
     try:
         test(app, *args, **kwargs)
     finally:
         StopCompleterServer(app, 'rust')
         handlers._server_state = old_server_state
コード例 #13
0
 def Wrapper(test_case_instance, *args, **kwargs):
     with IsolatedApp(custom_options) as app:
         try:
             test(test_case_instance, app, *args, **kwargs)
         finally:
             global shared_filepaths
             for filepath in shared_filepaths.get(app, []):
                 StopCompleterServer(app, 'cs', filepath)
コード例 #14
0
ファイル: __init__.py プロジェクト: navs82/ycmd
 def Wrapper( *args, **kwargs ):
   custom_options.update( { 'use_clangd': 'Always' } )
   with IgnoreExtraConfOutsideTestsFolder():
     with IsolatedApp( custom_options ) as app:
       clangd_completer.CLANGD_COMMAND = clangd_completer.NOT_CACHED
       try:
         test( app, *args, **kwargs )
       finally:
         StopCompleterServer( app, 'cpp' )
コード例 #15
0
def set_up_shared_app():
    global shared_app
    with patch('ycmd.completers.javascript.hook.'
               'ShouldEnableTernCompleter',
               return_value=False):
        shared_app = SetUpApp()
        WaitUntilCompleterServerReady(shared_app, 'javascript')
    yield
    StopCompleterServer(shared_app, 'javascript')
コード例 #16
0
def DebugInfo_ServerIsNotRunning_LogfilesDoNotExist_test( app ):
  with UserOption( 'server_keep_logfiles', False ):
    StopCompleterServer( app, 'javascript' )
    request_data = BuildRequest( filetype = 'javascript' )
    assert_that(
      app.post_json( '/debug_info', request_data ).json,
      matches_regexp( 'JavaScript completer debug information:\n'
                      '  Tern is not running\n'
                      '  Tern executable: .+' ) )
コード例 #17
0
 def Wrapper(*args, **kwargs):
     old_server_state = handlers._server_state
     app = SetUpApp()
     try:
         with CurrentWorkingDirectory(directory):
             test(app, *args, **kwargs)
     finally:
         StopCompleterServer(app, 'javascript')
         handlers._server_state = old_server_state
コード例 #18
0
ファイル: __init__.py プロジェクト: LiuChengqian90/viminfo
 def Wrapper(*args, **kwargs):
     with patch(
             'ycmd.completers.javascript.hook.'
             'ShouldEnableTernCompleter',
             return_value=False):
         with IsolatedApp() as app:
             try:
                 test(app, *args, **kwargs)
             finally:
                 StopCompleterServer(app, 'javascript')
コード例 #19
0
def set_up_shared_app():
  """Initializes the ycmd server as a WebTest application that will be shared
  by all tests using the SharedYcmd decorator in this package. Additional
  configuration that is common to these tests, like starting a semantic
  subserver, should be done here."""
  global shared_app
  shared_app = SetUpApp()
  StartJavaScriptCompleterServerInDirectory( shared_app, PathToTestFile() )
  yield
  StopCompleterServer( shared_app, 'java' )
コード例 #20
0
ファイル: debug_info_test.py プロジェクト: tianser/vim
def DebugInfo_ServerIsNotRunning_LogfilesDoNotExist_test(app):
    with UserOption('server_keep_logfiles', False):
        StopCompleterServer(app, 'python')
        request_data = BuildRequest(filetype='python')
        assert_that(
            app.post_json('/debug_info', request_data).json,
            matches_regexp('Python completer debug information:\n'
                           '  JediHTTP is not running\n'
                           '  JediHTTP executable: .+\n'
                           '  Python interpreter: .+'))
コード例 #21
0
 def Wrapper(test_case_instance, *args, **kwargs):
     with patch(
             'ycmd.completers.javascript.hook.'
             'ShouldEnableTernCompleter',
             return_value=False):
         with IsolatedApp(custom_options) as app:
             try:
                 test(test_case_instance, app, *args, **kwargs)
             finally:
                 StopCompleterServer(app, 'javascript')
コード例 #22
0
def app( request ):
  which = request.param[ 0 ]
  assert which == 'isolated' or which == 'shared'
  if which == 'isolated':
    with IsolatedApp( {} ) as app:
      yield app
      StopCompleterServer( app, 'javascript' )
  else:
    global shared_app
    ClearCompletionsCache()
    yield shared_app
コード例 #23
0
ファイル: __init__.py プロジェクト: tianser/vim
 def Wrapper(*args, **kwargs):
     old_server_state = handlers._server_state
     old_current_dir = os.getcwd()
     app = SetUpApp()
     os.chdir(PathToTestFile())
     try:
         test(app, *args, **kwargs)
     finally:
         StopCompleterServer(app, 'javascript')
         os.chdir(old_current_dir)
         handlers._server_state = old_server_state
コード例 #24
0
def set_up_shared_app():
  """Initializes the ycmd server as a WebTest application that will be shared
  by all tests using the SharedYcmd decorator in this package. Additional
  configuration that is common to these tests, like starting a semantic
  subserver, should be done here."""
  global shared_app
  shared_app = SetUpApp()
  with IgnoreExtraConfOutsideTestsFolder():
    StartJavaCompleterServerInDirectory(
        shared_app, PathToTestFile( DEFAULT_PROJECT_DIR ) )
  yield
  StopCompleterServer( shared_app, 'java' )
コード例 #25
0
def app(request):
    which = request.param[0]
    assert which == 'isolated' or which == 'shared'
    if which == 'isolated':
        with IsolatedApp({}) as app:
            yield app
            StopCompleterServer(app, 'rust')
    else:
        global shared_app
        ClearCompletionsCache()
        with IgnoreExtraConfOutsideTestsFolder():
            yield shared_app
コード例 #26
0
ファイル: conftest.py プロジェクト: CorinnaBuerger/dotfiles
def app(request):
    which = request.param[0]
    assert which == 'isolated' or which == 'shared'
    if which == 'isolated':
        with IsolatedApp(request.param[1]) as app:
            try:
                yield app
            finally:
                StopCompleterServer(app, 'go')
    else:
        global shared_app
        ClearCompletionsCache()
        yield shared_app
コード例 #27
0
def app(request):
    which = request.param[0]
    assert which == 'isolated' or which == 'shared'
    if which == 'isolated':
        with IsolatedApp(request.param[1]) as app:
            clangd_completer.CLANGD_COMMAND = clangd_completer.NOT_CACHED
            yield app
            StopCompleterServer(app, 'cpp')
    else:
        global shared_app
        ClearCompletionsCache()
        with IgnoreExtraConfOutsideTestsFolder():
            yield shared_app
コード例 #28
0
ファイル: debug_info_test.py プロジェクト: tianser/vim
def DebugInfo_ServerIsNotRunning_LogfilesExist_test(app):
    with UserOption('server_keep_logfiles', True):
        StopCompleterServer(app, 'go')
        request_data = BuildRequest(filetype='go')
        assert_that(
            app.post_json('/debug_info', request_data).json,
            matches_regexp('Go completer debug information:\n'
                           '  Gocode no longer running\n'
                           '  Gocode executable: .+\n'
                           '  Gocode logfiles:\n'
                           '    .+\n'
                           '    .+\n'
                           '  Godef executable: .+'))
コード例 #29
0
ファイル: __init__.py プロジェクト: wooloow/ycmd
def isolated_app(custom_options={}):
    """Defines a context manager to be used in cases where it is easier to
  specify user options of the isolated ycmdat some point inside the function.

  Example usage:

    def some_test( isolated_app ):
      with TemporaryTestDir() as tmp_dir:
        with isolated_app( user_options ) as app:

  """
    with IsolatedApp(custom_options) as app:
        try:
            yield app
        finally:
            StopCompleterServer(app, 'java')
コード例 #30
0
def app(request):
    which = request.param[0]
    assert which == 'isolated' or which == 'shared'
    if which == 'isolated':
        custom_options = request.param[1]
        with IsolatedApp(custom_options) as app:
            yield app
            # Shutdown the isolated app
            for filepath in shared_filepaths.get(app, []):
                StopCompleterServer(app, 'cs', filepath)

    else:
        global shared_app
        ClearCompletionsCache()
        with IgnoreExtraConfOutsideTestsFolder():
            yield shared_app