コード例 #1
0
ファイル: debug_info_test.py プロジェクト: ctomiao2/vim
def DebugInfo_ProjectDirectory_test( app ):
  project_dir = PathToTestFile( 'td' )
  StartGoCompleterServerInDirectory( app, project_dir )
  assert_that(
    app.post_json( '/debug_info', BuildRequest( filetype = 'go' ) ).json,
    has_entry( 'completer', has_entries( {
      'name': 'Go',
      'servers': contains( has_entries( {
        'name': 'gopls',
        'is_running': instance_of( bool ),
        'executable': contains( instance_of( str ),
                                instance_of( str ),
                                instance_of( str ),
                                instance_of( str ) ),
        'address': None,
        'port': None,
        'pid': instance_of( int ),
        'logfiles': contains( instance_of( str ) ),
        'extras': contains(
          has_entries( {
            'key': 'Server State',
            'value': instance_of( str ),
          } ),
          has_entries( {
            'key': 'Project Directory',
            'value': PathToTestFile(),
          } ),
          has_entries( {
            'key': 'Settings',
            'value': '{}'
          } ),
        )
      } ) ),
    } ) )
  )
コード例 #2
0
def Subcommands_Format_Range_test(app):
    project_dir = PathToTestFile()
    StartGoCompleterServerInDirectory(app, project_dir)

    filepath = os.path.join(project_dir, 'goto.go')

    RunTest(
        app, {
            'description': 'Formatting is applied on some part of the file',
            'request': {
                'command': 'Format',
                'filepath': filepath,
                'range': {
                    'start': {
                        'line_num': 7,
                        'column_num': 1,
                    },
                    'end': {
                        'line_num': 9,
                        'column_num': 2
                    }
                },
                'options': {
                    'tab_size': 4,
                    'insert_spaces': False
                }
            },
            'expect': {
                'response':
                requests.codes.ok,
                'data':
                has_entries({
                    'fixits':
                    contains_exactly(
                        has_entries({
                            'chunks':
                            contains_exactly(
                                ChunkMatcher(
                                    'fn unformatted_function(param: bool) -> bool {\n'
                                    '\treturn param;\n'
                                    '}\n'
                                    '\n'
                                    'fn \n'
                                    'main()\n'
                                    '                                {\n'
                                    '        unformatted_function( false );\n'
                                    '}\n', LocationMatcher(filepath, 1, 1),
                                    LocationMatcher(filepath, 9, 1)), )
                        }))
                })
            }
        })
コード例 #3
0
def ServerManagement_CloseServer_Unclean_test(rm_tree, app):
    StartGoCompleterServerInDirectory(app, PathToTestFile())

    app.post_json(
        '/run_completer_command',
        BuildRequest(filetype='go', command_arguments=['StopServer']))

    request_data = BuildRequest(filetype='go')
    assert_that(
        app.post_json('/debug_info', request_data).json,
        has_entry(
            'completer',
            has_entry('servers',
                      contains_exactly(has_entry('is_running', False)))))
コード例 #4
0
def DebugInfo_ProjectDirectory_test(app):
    project_dir = PathToTestFile('td')
    StartGoCompleterServerInDirectory(app, project_dir)
    assert_that(
        app.post_json('/debug_info', BuildRequest(filetype='go')).json,
        has_entry(
            'completer',
            has_entries({
                'name':
                'Go',
                'servers':
                contains_exactly(
                    has_entries({
                        'name':
                        'gopls',
                        'is_running':
                        instance_of(bool),
                        'executable':
                        contains_exactly(instance_of(str), instance_of(str),
                                         instance_of(str), instance_of(str)),
                        'address':
                        None,
                        'port':
                        None,
                        'pid':
                        instance_of(int),
                        'logfiles':
                        contains_exactly(instance_of(str)),
                        'extras':
                        contains_exactly(
                            has_entries({
                                'key': 'Server State',
                                'value': instance_of(str),
                            }),
                            has_entries({
                                'key': 'Project Directory',
                                'value': PathToTestFile(),
                            }),
                            has_entries({
                                'key':
                                'Settings',
                                'value':
                                matches_regexp(
                                    '{\n  "fuzzyMatching": false,\\s?\n'
                                    '  "hoverKind": "Structured"\n}')
                            }),
                        )
                    })),
            })))
コード例 #5
0
def Subcommands_Format_WholeFile_test(app):
    # RLS can't execute textDocument/formatting if any file
    # under the project root has errors, so we need to use
    # a different project just for formatting.
    # For further details check https://github.com/go-lang/rls/issues/1397
    project_dir = PathToTestFile()
    StartGoCompleterServerInDirectory(app, project_dir)

    filepath = os.path.join(project_dir, 'goto.go')

    RunTest(
        app, {
            'description': 'Formatting is applied on the whole file',
            'request': {
                'command': 'Format',
                'filepath': filepath,
                'options': {
                    'tab_size': 2,
                    'insert_spaces': True
                }
            },
            'expect': {
                'response':
                requests.codes.ok,
                'data':
                has_entries({
                    'fixits':
                    contains_exactly(
                        has_entries({
                            'chunks':
                            contains_exactly(
                                ChunkMatcher('', LocationMatcher(
                                    filepath, 8, 1),
                                             LocationMatcher(filepath, 9, 1)),
                                ChunkMatcher('\tdummy() //GoTo\n',
                                             LocationMatcher(filepath, 9, 1),
                                             LocationMatcher(filepath, 9, 1)),
                                ChunkMatcher('',
                                             LocationMatcher(filepath, 12, 1),
                                             LocationMatcher(filepath, 13, 1)),
                                ChunkMatcher('\tdiagnostics_test\n',
                                             LocationMatcher(filepath, 13, 1),
                                             LocationMatcher(filepath, 13, 1)),
                            )
                        }))
                })
            }
        })
コード例 #6
0
def ServerManagement_RestartServer_test(app):
    filepath = PathToTestFile('goto.go')
    StartGoCompleterServerInDirectory(app, filepath)

    AssertGoCompleterServerIsRunning(app, True)

    app.post_json(
        '/run_completer_command',
        BuildRequest(
            filepath=filepath,
            filetype='go',
            command_arguments=['RestartServer'],
        ),
    )

    WaitUntilCompleterServerReady(app, 'go')

    AssertGoCompleterServerIsRunning(app, True)
コード例 #7
0
def ServerManagement_StopServerTwice_test(app):
    StartGoCompleterServerInDirectory(app, PathToTestFile())

    app.post_json(
        '/run_completer_command',
        BuildRequest(
            filetype='go',
            command_arguments=['StopServer'],
        ),
    )

    AssertGoCompleterServerIsRunning(app, False)

    # Stopping a stopped server is a no-op
    app.post_json(
        '/run_completer_command',
        BuildRequest(
            filetype='go',
            command_arguments=['StopServer'],
        ),
    )

    AssertGoCompleterServerIsRunning(app, False)