Ejemplo n.º 1
0
    def Start(self, idle_suicide_seconds=60, check_interval_seconds=60 * 10):
        # The temp options file is deleted by ycmd during startup
        with NamedTemporaryFile(mode='w+', delete=False) as options_file:
            json.dump(self._options_dict, options_file)
            options_file.flush()
            self._port = GetUnusedLocalhostPort()
            self._location = 'http://127.0.0.1:' + str(self._port)

            # Define environment variable to enable subprocesses coverage. See:
            # http://coverage.readthedocs.org/en/coverage-4.0.3/subprocess.html
            env = os.environ.copy()
            SetEnviron(env, 'COVERAGE_PROCESS_START', '.coveragerc')

            ycmd_args = [
                sys.executable,
                PATH_TO_YCMD,
                '--port={0}'.format(self._port),
                '--options_file={0}'.format(options_file.name),
                '--log=debug',
                '--idle_suicide_seconds={0}'.format(idle_suicide_seconds),
                '--check_interval_seconds={0}'.format(check_interval_seconds),
            ]

            self._stdout = os.path.join(PathToCreatedTempDir(), 'test.log')
            with OpenForStdHandle(self._stdout) as stdout:
                _popen_handle = SafePopen(ycmd_args,
                                          stdin_windows=subprocess.PIPE,
                                          stdout=stdout,
                                          stderr=subprocess.STDOUT,
                                          env=env)
                self.server = psutil.Process(_popen_handle.pid)
Ejemplo n.º 2
0
  def Start( self, idle_suicide_seconds = 60,
             check_interval_seconds = 60 * 10 ):
    # The temp options file is deleted by ycmd during startup
    with NamedTemporaryFile( mode = 'w+', delete = False ) as options_file:
      json.dump( self._options_dict, options_file )
      options_file.flush()
      self._port = GetUnusedLocalhostPort()
      self._location = 'http://127.0.0.1:' + str( self._port )

      # Define environment variable to enable subprocesses coverage. See:
      # http://coverage.readthedocs.org/en/coverage-4.0.3/subprocess.html
      env = os.environ.copy()
      SetEnviron( env, 'COVERAGE_PROCESS_START', '.coveragerc' )

      ycmd_args = [
        sys.executable,
        PATH_TO_YCMD,
        '--port={0}'.format( self._port ),
        '--options_file={0}'.format( options_file.name ),
        '--log=debug',
        '--idle_suicide_seconds={0}'.format( idle_suicide_seconds ),
        '--check_interval_seconds={0}'.format( check_interval_seconds ),
      ]

      stdout = CreateLogfile(
          LOGFILE_FORMAT.format( port = self._port, std = 'stdout' ) )
      stderr = CreateLogfile(
          LOGFILE_FORMAT.format( port = self._port, std = 'stderr' ) )
      self._logfiles.extend( [ stdout, stderr ] )
      ycmd_args.append( '--stdout={0}'.format( stdout ) )
      ycmd_args.append( '--stderr={0}'.format( stderr ) )

      _popen_handle = SafePopen( ycmd_args,
                                 stdin_windows = subprocess.PIPE,
                                 stdout = subprocess.PIPE,
                                 stderr = subprocess.PIPE,
                                 env = env )
      self._servers.append( psutil.Process( _popen_handle.pid ) )

      self._WaitUntilReady()
      extra_conf = PathToTestFile( 'client', '.ycm_extra_conf.py' )
      self.PostRequest( 'load_extra_conf_file', { 'filepath': extra_conf } )