コード例 #1
0
 def test_GetCompleter_RAFromUserOption(self, *args):
     user_options = user_options_store.GetAll().copy(
         rust_toolchain_root='rust-analyzer')
     assert_that(
         GetCompleter(user_options)._rust_root, equal_to('rust-analyzer'))
     expected = os.path.join('rust-analyzer', 'bin', 'rust-analyzer')
     assert_that(GetCompleter(user_options)._ra_path, equal_to(expected))
コード例 #2
0
    def setUp(self):
        options = dict(user_options_store.DefaultOptions())
        options.update(DEFAULT_CLIENT_OPTIONS)
        user_options_store.SetAll(options)

        self.server_state = YouCompleteMe(user_options_store.GetAll())
        pass
コード例 #3
0
    def _SetUpServer(self):
        self._available_completers = {}
        self._user_notified_about_crash = False
        self._filetypes_with_keywords_loaded = set()
        self._server_is_ready_with_cache = False
        self._message_poll_request = None

        base.LoadJsonDefaultsIntoVim()
        user_options_store.SetAll(base.BuildServerConf())
        self._user_options = user_options_store.GetAll()
        self._omnicomp = OmniCompleter(self._user_options)
        self._buffers = BufferDict(self._user_options)

        self._SetLogLevel()

        hmac_secret = os.urandom(HMAC_SECRET_LENGTH)
        options_dict = dict(self._user_options)
        options_dict['hmac_secret'] = utils.ToUnicode(
            base64.b64encode(hmac_secret))
        options_dict['server_keep_logfiles'] = self._user_options[
            'keep_logfiles']

        # The temp options file is deleted by ycmd during startup.
        with NamedTemporaryFile(delete=False, mode='w+') as options_file:
            json.dump(options_dict, options_file)

        server_port = utils.GetUnusedLocalhostPort()

        BaseRequest.server_location = 'http://127.0.0.1:' + str(server_port)
        BaseRequest.hmac_secret = hmac_secret

        this_file_path = os.path.dirname(os.path.realpath(__file__))
        tabnine_binary_path = os.path.join(this_file_path, '../../binaries/')

        args = [
            '--client=vim', '--port={0}'.format(server_port),
            '--options_file={0}'.format(options_file.name),
            '--log={0}'.format(self._user_options['log_level']),
            '--idle_suicide_seconds={0}'.format(SERVER_IDLE_SUICIDE_SECONDS)
        ]

        self._server_stdout = utils.CreateLogfile(
            SERVER_LOGFILE_FORMAT.format(port=server_port, std='stdout'))
        self._server_stderr = utils.CreateLogfile(
            SERVER_LOGFILE_FORMAT.format(port=server_port, std='stderr'))
        args.append('--stdout={0}'.format(self._server_stdout))
        args.append('--stderr={0}'.format(self._server_stderr))

        if self._user_options['keep_logfiles']:
            args.append('--keep_logfiles')

        try:
            self._server_popen = start_tabnine_proc(
                cmd_args=args, binary_dir=tabnine_binary_path)
        except RuntimeError as error:
            error_message = str(error)
            self._logger.exception(error_message)
            vimsupport.PostVimMessage(error_message)
            return
コード例 #4
0
def WorkingDir_UseFilePath_test(app):
    ok_(GetCurrentDirectory() != DATA_DIR, ('Please run this test from a '
                                            'different directory'))

    completer = FilenameCompleter(user_options_store.GetAll())

    data = _CompletionResultsForLine(completer, 'ls ./include/')
    assert_that(data, contains_inanyorder(('Qt', '[Dir]'), ('QtGui', '[Dir]')))
コード例 #5
0
def WorkingDir_UseFilePath_test(app):
    ok_(GetCurrentDirectory() != DATA_DIR, ('Please run this test from a '
                                            'different directory'))

    completer = FilenameCompleter(user_options_store.GetAll())

    data = sorted(_CompletionResultsForLine(completer, 'ls ./include/'))
    eq_([('Qt', '[Dir]'), ('QtGui', '[Dir]')], data)
コード例 #6
0
def UserOption(key, value):
    try:
        current_options = dict(user_options_store.GetAll())
        user_options = current_options.copy()
        user_options.update({key: value})
        handlers.UpdateUserOptions(user_options)
        yield user_options
    finally:
        handlers.UpdateUserOptions(current_options)
コード例 #7
0
def SetUpYCM():
    from ycm import base
    from ycmd import user_options_store
    from ycm.youcompleteme import YouCompleteMe

    base.LoadJsonDefaultsIntoVim()

    user_options_store.SetAll(base.BuildServerConf())

    return YouCompleteMe(user_options_store.GetAll())
コード例 #8
0
def IsolatedApp(custom_options={}):
    old_server_state = handlers._server_state
    old_extra_conf_store_state = extra_conf_store.Get()
    old_options = user_options_store.GetAll()
    try:
        yield SetUpApp(custom_options)
    finally:
        handlers._server_state = old_server_state
        extra_conf_store.Set(old_extra_conf_store_state)
        user_options_store.SetAll(old_options)
コード例 #9
0
def IsolatedApp( custom_options = {} ):
  old_server_state = handlers._server_state
  old_extra_conf_store_state = extra_conf_store.Get()
  old_options = user_options_store.GetAll()
  try:
    with IgnoreExtraConfOutsideTestsFolder():
      yield SetUpApp( custom_options )
  finally:
    handlers._server_state = old_server_state
    extra_conf_store.Set( old_extra_conf_store_state )
    user_options_store.SetAll( old_options )
コード例 #10
0
def WorkingDir_UseClientWorkingDirectory_test(app):
    test_dir = os.path.join(DATA_DIR, 'include')
    ok_(GetCurrentDirectory() != test_dir, ('Please run this test from a '
                                            'different directory'))

    completer = FilenameCompleter(user_options_store.GetAll())

    # We supply working_dir in the request, so we expect results to be
    # relative to the supplied path.
    data = _CompletionResultsForLine(completer, 'ls ./',
                                     {'working_dir': test_dir})
    assert_that(data, contains_inanyorder(('Qt', '[Dir]'), ('QtGui', '[Dir]')))
コード例 #11
0
def WorkingDir_UseServerWorkingDirectory_test(app):
    test_dir = os.path.join(DATA_DIR, 'include')
    with CurrentWorkingDirectory(test_dir) as old_current_dir:
        ok_(old_current_dir != test_dir,
            ('Please run this test from a different '
             'directory'))

        completer = FilenameCompleter(user_options_store.GetAll())

        # We don't supply working_dir in the request, so the current working
        # directory is used.
        data = sorted(_CompletionResultsForLine(completer, 'ls ./'))
        eq_([('Qt', '[Dir]'), ('QtGui', '[Dir]')], data)
コード例 #12
0
def WorkingDir_UseServerWorkingDirectory_Unicode_test(app):
    test_dir = os.path.join(TEST_DIR, 'testdata', 'filename_completer', '∂†∫')
    with CurrentWorkingDirectory(test_dir) as old_current_dir:
        ok_(old_current_dir != test_dir,
            ('Please run this test from a different '
             'directory'))

        completer = FilenameCompleter(user_options_store.GetAll())

        # We don't supply working_dir in the request, so the current working
        # directory is used.
        data = sorted(_CompletionResultsForLine(completer, 'ls ./'))
        eq_([('†es†.txt', '[File]')], data)
コード例 #13
0
def SetUpYCM():
    from ycm import base, paths
    from ycmd import user_options_store, utils
    from ycm.youcompleteme import YouCompleteMe

    base.LoadJsonDefaultsIntoVim()

    user_options_store.SetAll(base.BuildServerConf())

    popen_args = [
        paths.PathToPythonInterpreter(),
        paths.PathToCheckCoreVersion()
    ]

    if utils.SafePopen(popen_args).wait() == 2:
        raise RuntimeError('YCM support libs too old, PLEASE RECOMPILE.')

    return YouCompleteMe(user_options_store.GetAll())
コード例 #14
0
    def _SetUpServer(self):
        self._available_completers = {}
        self._user_notified_about_crash = False
        self._filetypes_with_keywords_loaded = set()
        self._server_is_ready_with_cache = False
        self._message_poll_request = None

        base.LoadJsonDefaultsIntoVim()
        user_options_store.SetAll(base.BuildServerConf())
        self._user_options = user_options_store.GetAll()
        self._omnicomp = OmniCompleter(self._user_options)
        self._buffers = BufferDict(self._user_options)

        self._SetLogLevel()

        hmac_secret = os.urandom(HMAC_SECRET_LENGTH)
        options_dict = dict(self._user_options)
        options_dict['hmac_secret'] = utils.ToUnicode(
            base64.b64encode(hmac_secret))
        options_dict['server_keep_logfiles'] = self._user_options[
            'keep_logfiles']

        # The temp options file is deleted by ycmd during startup.
        with NamedTemporaryFile(delete=False, mode='w+') as options_file:
            json.dump(options_dict, options_file)

        server_port = utils.GetUnusedLocalhostPort()

        BaseRequest.server_location = 'http://127.0.0.1:' + str(server_port)
        BaseRequest.hmac_secret = hmac_secret

        try:
            python_interpreter = paths.PathToPythonInterpreter()
        except RuntimeError as error:
            error_message = ("Unable to start the ycmd server. {0}. "
                             "Correct the error then restart the server "
                             "with ':YcmRestartServer'.".format(
                                 str(error).rstrip('.')))
            self._logger.exception(error_message)
            vimsupport.PostVimMessage(error_message)
            return

        args = [
            python_interpreter,
            paths.PathToServerScript(), '--port={0}'.format(server_port),
            '--options_file={0}'.format(options_file.name),
            '--log={0}'.format(self._user_options['log_level']),
            '--idle_suicide_seconds={0}'.format(SERVER_IDLE_SUICIDE_SECONDS)
        ]

        self._server_stdout = utils.CreateLogfile(
            SERVER_LOGFILE_FORMAT.format(port=server_port, std='stdout'))
        self._server_stderr = utils.CreateLogfile(
            SERVER_LOGFILE_FORMAT.format(port=server_port, std='stderr'))
        args.append('--stdout={0}'.format(self._server_stdout))
        args.append('--stderr={0}'.format(self._server_stderr))

        if self._user_options['keep_logfiles']:
            args.append('--keep_logfiles')

        self._server_popen = utils.SafePopen(args,
                                             stdin_windows=PIPE,
                                             stdout=PIPE,
                                             stderr=PIPE)
コード例 #15
0
 def test_GetCompleter_WarnsAboutOldConfig(self, logger):
     user_options = user_options_store.GetAll().copy(
         rls_binary_path='/does/not/exist')
     GetCompleter(user_options)
     logger.warning.assert_called_with(
         'rls_binary_path detected. Did you mean rust_toolchain_root?')
コード例 #16
0
def GetCompleter_RoslynNotFound_test(*args):
    assert_that(not GetCompleter(user_options_store.GetAll()))
コード例 #17
0
def GetCompleter_RlsNotFound_test(*args):
    ok_(not GetCompleter(user_options_store.GetAll()))
コード例 #18
0
def GetCompleter_GoplsFromUserOption_test(*args):
    user_options = user_options_store.GetAll().copy(gopls_binary_path='gopls')
    assert_that(GetCompleter(user_options)._gopls_path, equal_to('gopls'))
コード例 #19
0
ファイル: debug_info_test.py プロジェクト: wooloow/ycmd
 def test_GetCompleter_CustomPathToServer_NotAFile( self, *args ):
   user_options = user_options_store.GetAll().copy(
     roslyn_binary_path = 'does-not-exist' )
   assert_that( not GetCompleter( user_options ) )
コード例 #20
0
ファイル: debug_info_test.py プロジェクト: wooloow/ycmd
 def test_GetCompleter_RoslynFound( self ):
   assert_that( GetCompleter( user_options_store.GetAll() ) )
コード例 #21
0
 def setUp(self):
     with patch('vim.eval', side_effect=self.VimEval):
         user_options_store.SetAll(base.BuildServerConf())
         self.ycm = YouCompleteMe(user_options_store.GetAll())
コード例 #22
0
ファイル: handlers.py プロジェクト: zyd213/RoboWare-Studio
def SetServerStateToDefaults():
  global _server_state, _logger
  _logger = logging.getLogger( __name__ )
  user_options_store.LoadDefaults()
  _server_state = server_state.ServerState( user_options_store.GetAll() )
  extra_conf_store.Reset()
コード例 #23
0
def GetCompleter_RlsFound_test():
    ok_(GetCompleter(user_options_store.GetAll()))
コード例 #24
0
 def test_ShouldEnableTypeScriptCompleter_TsserverNotFound(self, *args):
     user_options = user_options_store.GetAll()
     assert_that(not ShouldEnableTypeScriptCompleter(user_options))
コード例 #25
0
def GetCompleter_RoslynFound_test():
    assert_that(GetCompleter(user_options_store.GetAll()))
コード例 #26
0
ファイル: test_utils.py プロジェクト: zhaopuming/ycmd
def ChangeSpecificOptions( options ):
  current_options = dict( user_options_store.GetAll() )
  current_options.update( options )
  handlers.UpdateUserOptions( current_options )
コード例 #27
0
def GetCompleter_RoslynFromUserOption_test(*args):
    user_options = user_options_store.GetAll().copy(
        roslyn_binary_path='roslyn')
    assert_that(GetCompleter(user_options)._roslyn_path, equal_to('roslyn'))
コード例 #28
0
ファイル: handlers.py プロジェクト: symbolix/ycmd
def SetServerStateToDefaults():
  global SERVER_STATE, LOGGER
  LOGGER = logging.getLogger( __name__ )
  user_options_store.LoadDefaults()
  SERVER_STATE = server_state.ServerState( user_options_store.GetAll() )
  extra_conf_store.Reset()
コード例 #29
0
 def test_ShouldEnableTypeScriptCompleter_NodeAndTsserverFound(self):
     user_options = user_options_store.GetAll()
     assert_that(ShouldEnableTypeScriptCompleter(user_options))
コード例 #30
0
 def test_GetCompleter_InvalidRustRootFromUser(self, *args):
     user_options = user_options_store.GetAll().copy(
         rust_toolchain_root='/does/not/exist')
     assert_that(not GetCompleter(user_options))