Skip to content

Conversation

@tintoy
Copy link
Collaborator

@tintoy tintoy commented Nov 16, 2017

Hey - I'm starting to add more tests for the LSP client.

@codecov
Copy link

codecov bot commented Nov 16, 2017

Codecov Report

Merging #47 into master will increase coverage by 9.3%.
The diff coverage is 98.85%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #47 +/- ## ========================================= + Coverage 55.21% 64.52% +9.3%  ========================================= Files 233 234 +1 Lines 3142 3309 +167 ========================================= + Hits 1735 2135 +400  + Misses 1407 1174 -233
Impacted Files Coverage Δ
src/Client/Processes/NamedPipeServerProcess.cs 88.88% <100%> (+5.55%) ⬆️
test/Client.Tests/Logging/TestOutputLogger.cs 82.6% <100%> (+2.6%) ⬆️
test/Client.Tests/ConnectionTests.cs 100% <100%> (ø) ⬆️
test/Client.Tests/ClientTests.cs 100% <100%> (ø)
test/Client.Tests/TestBase.cs 85.29% <50%> (-2.21%) ⬇️
src/Client/Protocol/LspConnection.cs 67.94% <85.71%> (+19.88%) ⬆️
src/Client/LanguageClientRegistration.cs 9.52% <0%> (+9.52%) ⬆️
src/Lsp/Converters/MarkedStringConverter.cs 89.47% <0%> (+10.52%) ⬆️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe0a81a...ba583fd. Read the comment docs.

@tintoy
Copy link
Collaborator Author

tintoy commented Nov 16, 2017

@david-driscoll - would you mind having a look at ClientTests.cs and letting me know what you think? I could reduce the amount of boilerplate at the expense of more "magic", but I think maybe the first test I've added strikes a decent balance between boilerplate and magic 😁

@tintoy
Copy link
Collaborator Author

tintoy commented Nov 16, 2017

BTW, I can't see the AppVeyor build so I'll just have to assume it's working :)

@tintoy
Copy link
Collaborator Author

tintoy commented Nov 16, 2017

Failing, I meant failing 🤣

@david-driscoll
Copy link
Member

I'll add you to the appveyor team

/// Ensure that the language client can successfully request Hover information.
/// </summary>
[Fact(DisplayName = "Language client can successfully request hover info")]
public async Task Hover_Success()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should makes things so much easier to integration test... and we can finally make sure LanguageServer is working correctly.

@david-driscoll
Copy link
Member

And here's the error fyi:

 System.AggregateException : One or more errors occurred. (Error processing request '2' (500): Error processing request: Assert.Equal() Failure � (pos 0) Expected: \Foo.txt Actual: � (pos 0)) (One or more errors occurred. (Safe handle has been closed)) ---- OmniSharp.Extensions.LanguageServerProtocol.Client.LspRequestException : Error processing request '2' (500): Error processing request: Assert.Equal() Failure � (pos 0) Expected: \Foo.txt Actual: � (pos 0) ---- System.AggregateException : One or more errors occurred. (Safe handle has been closed) -------- System.ObjectDisposedException : Safe handle has been closed Stack Trace: ----- Inner Stack Trace #1 (OmniSharp.Extensions.LanguageServerProtocol.Client.LspRequestException) ----- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() C:\projects\csharp-language-server-protocol\src\Client\Protocol\LspConnection.cs(458,0): at OmniSharp.Extensions.LanguageServerProtocol.Client.Protocol.LspConnection.<SendRequest>d__38`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() C:\projects\csharp-language-server-protocol\src\Client\Clients\TextDocumentClient.cs(79,0): at OmniSharp.Extensions.LanguageServerProtocol.Client.Clients.TextDocumentClient.<PositionalRequest>d__6`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() C:\projects\csharp-language-server-protocol\test\Client.Tests\ClientTests.cs(86,0): at OmniSharp.Extensions.LanguageServerProtocol.Client.Tests.ClientTests.<Hover_Success>d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() ----- Inner Stack Trace #2 (System.AggregateException) ----- at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(Boolean throwOnFirstException) at System.Threading.CancellationTokenSource.NotifyCancellation(Boolean throwOnFirstException) at System.Threading.CancellationTokenSource.Cancel(Boolean throwOnFirstException) at System.Threading.CancellationTokenSource.Cancel() C:\projects\csharp-language-server-protocol\src\Client\Protocol\LspConnection.cs(282,0): at OmniSharp.Extensions.LanguageServerProtocol.Client.Protocol.LspConnection.Disconnect(Boolean flushOutgoing) C:\projects\csharp-language-server-protocol\src\Client\Protocol\LspConnection.cs(171,0): at OmniSharp.Extensions.LanguageServerProtocol.Client.Protocol.LspConnection.Dispose() at System.Reactive.Disposables.CompositeDisposable.Dispose() C:\projects\csharp-language-server-protocol\test\Client.Tests\TestBase.cs(88,0): at OmniSharp.Extensions.LanguageServerProtocol.Client.Tests.TestBase.Dispose(Boolean disposing) C:\projects\csharp-language-server-protocol\test\Client.Tests\TestBase.cs(72,0): at OmniSharp.Extensions.LanguageServerProtocol.Client.Tests.TestBase.Dispose() C:\Dev\xunit\xunit\src\xunit.execution\Extensions\ReflectionAbstractionExtensions.cs(77,0): at ReflectionAbstractionExtensions.DisposeTestClass(ITest test, Object testClass, IMessageBus messageBus, ExecutionTimer timer, CancellationTokenSource cancellationTokenSource) ----- Inner Stack Trace ----- at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success) at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success) at Interop.Kernel32.CancelIoEx(SafeHandle handle, NativeOverlapped* lpOverlapped) at System.IO.Pipes.PipeCompletionSource`1.Cancel() at System.IO.Pipes.PipeCompletionSource`1.<>c.<RegisterForCancellation>b__14_0(Object thisRef) at System.Threading.CancellationCallbackInfo.ExecutionContextCallback(Object obj) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.CancellationCallbackInfo.ExecuteCallback() at System.Threading.CancellationTokenSource.CancellationCallbackCoreWork(CancellationCallbackCoreWorkArguments args) at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(Boolean throwOnFirstException 
@tintoy
Copy link
Collaborator Author

tintoy commented Nov 16, 2017

Oops! Guess that wasn't so cross-platform after all (was on a mac when I tested it, so I guess the test will need to use a different path depending on OS). Will sort that out shortly :)

@tintoy
Copy link
Collaborator Author

tintoy commented Nov 16, 2017

BTW, have you seen Demystifier? Makes those stack traces a million times easier to read...

@tintoy
Copy link
Collaborator Author

tintoy commented Nov 16, 2017

@david-driscoll Here's a Demystifier example: https://github.com/DimensionDataResearch/daas-demo/blob/master/src/DaaSDemo.Provisioning.Host/Program.cs#L36

It's only a test-level dependency, but I thought it'd be worth discussing before trying to add it (it's been pretty high-value in my own projects so far).

@david-driscoll
Copy link
Member

I'd seen some stuff on twitter about it. I'm fine if you want to bring it in and make things look better.

@tintoy
Copy link
Collaborator Author

tintoy commented Nov 16, 2017

Cool - I'll look into it once the travis build starts working again (just want to be sure I've knocked the xplat paths issue on the head first).

@tintoy
Copy link
Collaborator Author

tintoy commented Nov 16, 2017

Hmm - looks like keyserver.ubuntu.com is down, the travis build keeps failing during the setup stage :-/

Will re-test on my mac. Yep, works on Windows and non-Windows.

@tintoy tintoy changed the title [WIP] Add request-level tests for LspConnection Add request-level tests for LspConnection Nov 16, 2017
@tintoy
Copy link
Collaborator Author

tintoy commented Nov 16, 2017

Ok - if the builds pass then this should be ready for review :)

Copy link
Member

@david-driscoll david-driscoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

[Fact(DisplayName = "Client connection can handle request from server")]
public async Task Server_HandleRequest_Success()
{
LspConnection clientConnection = await CreateClientConnection();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick, if we make CreateClientConnection return a disposable we can wrap all these calls in a using and remove some boilerplate with disconnect.

However that can be changed later.

@david-driscoll david-driscoll merged commit a77fb5d into OmniSharp:master Nov 16, 2017
@tintoy tintoy deleted the feature/client-tests branch November 16, 2017 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants