def Wrapper(*args, **kwargs): with IgnoreExtraConfOutsideTestsFolder(): with IsolatedApp(custom_options) as app: try: test(app, *args, **kwargs) finally: StopCompleterServer(app, 'foo')
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)
def Wrapper(*args, **kwargs): with IsolatedApp() as app: try: with CurrentWorkingDirectory(directory): test(app, *args, **kwargs) finally: StopCompleterServer(app, 'javascript')
def ServerManagement_StopServer_Killed_test( app ): StartClangd( app ) process = psutil.Process( GetPid( app ) ) process.terminate() process.wait( timeout = 5 ) StopCompleterServer( app, 'cpp', '' ) CheckStopped( app )
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')
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 ) )
def set_up_shared_app(): global shared_app shared_app = SetUpApp() with IgnoreExtraConfOutsideTestsFolder(): StartGoCompleterServerInDirectory(shared_app, PathToTestFile()) yield StopCompleterServer(shared_app, 'go')
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)
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.' ) )
def set_up_shared_app(): global shared_app shared_app = SetUpApp() with IgnoreExtraConfOutsideTestsFolder(): StartRustCompleterServerInDirectory(shared_app, PathToTestFile('common', 'src')) yield StopCompleterServer(shared_app, 'rust')
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
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
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)
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' )
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')
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: .+' ) )
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
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')
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' )
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: .+'))
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')
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
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
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' )
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
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
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
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: .+'))
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')
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