Skip to content

Commit d82ff82

Browse files
Added target framework for netcoreapp2.1 for tests (#253)
* Added target framework for netcoreapp2.1 * fixed test failures on appveyor
1 parent 43e946c commit d82ff82

12 files changed

+35
-15
lines changed

src/JsonRpc.Testing/JsonRpcServerTestBase.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ protected virtual void ConfigureServerInputOutput(PipeReader inMemoryReader, Pip
3333
Action<JsonRpcServerOptions> clientOptionsAction,
3434
Action<JsonRpcServerOptions> serverOptionsAction)
3535
{
36-
var clientPipe = new Pipe();
37-
var serverPipe = new Pipe();
36+
var clientPipe = new Pipe(TestOptions.DefaultPipeOptions);
37+
var serverPipe = new Pipe(TestOptions.DefaultPipeOptions);
3838

3939
var clientTask = JsonRpcServer.From(options => {
4040
options

src/JsonRpc.Testing/JsonRpcTestOptions.cs

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO.Pipelines;
23
using Microsoft.Extensions.Logging;
34
using Microsoft.Extensions.Logging.Abstractions;
45

@@ -25,5 +26,9 @@ public JsonRpcTestOptions(ILoggerFactory clientLoggerFactory, ILoggerFactory ser
2526
public TimeSpan SettleTimeSpan { get; internal set; } = TimeSpan.FromMilliseconds(50);
2627
public TimeSpan SettleTimeout { get; internal set; } = TimeSpan.FromMilliseconds(500);
2728
public TimeSpan TestTimeout { get; internal set; } = TimeSpan.FromSeconds(30);
29+
30+
public PipeOptions DefaultPipeOptions { get; internal set; } =
31+
new PipeOptions();
32+
2833
}
2934
}

src/JsonRpc.Testing/JsonRpcTestOptionsExtensions.cs

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO.Pipelines;
23
using Microsoft.Extensions.Logging;
34

45
namespace OmniSharp.Extensions.JsonRpc.Testing
@@ -30,5 +31,10 @@ public static JsonRpcTestOptions WithTestTimeout(this JsonRpcTestOptions options
3031
options.TestTimeout = testTimeout;
3132
return options;
3233
}
34+
public static JsonRpcTestOptions WithDefaultPipeOptions(this JsonRpcTestOptions options, PipeOptions pipeOptions)
35+
{
36+
options.DefaultPipeOptions = pipeOptions;
37+
return options;
38+
}
3339
}
3440
}

src/JsonRpc.Testing/Settler.cs

+2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ namespace OmniSharp.Extensions.JsonRpc.Testing
1010
{
1111
class Settler : ISettler, IRequestSettler
1212
{
13+
private readonly TimeSpan _timeout;
1314
private readonly CancellationToken _cancellationToken;
1415
private readonly IObservable<Unit> _settle;
1516
private readonly IObserver<int> _requester;
1617

1718
public Settler(TimeSpan waitTime, TimeSpan timeout, CancellationToken cancellationToken)
1819
{
20+
_timeout = timeout;
1921
_cancellationToken = cancellationToken;
2022
var subject = new Subject<int>();
2123
var data = subject;

src/Testing/LanguageProtocolTestBase.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ protected virtual void ConfigureServerInputOutput(PipeReader clientOutput, PipeW
4242
Action<LanguageClientOptions> clientOptionsAction,
4343
Action<LanguageServerOptions> serverOptionsAction)
4444
{
45-
var clientPipe = new Pipe(new PipeOptions(readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false));
46-
var serverPipe = new Pipe(new PipeOptions(readerScheduler: PipeScheduler.Inline, writerScheduler: PipeScheduler.Inline, useSynchronizationContext: false));
45+
var clientPipe = new Pipe(TestOptions.DefaultPipeOptions);
46+
var serverPipe = new Pipe(TestOptions.DefaultPipeOptions);
4747

4848
_client = LanguageClient.PreInit(options => {
4949
options

test/Client.Tests/Client.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
55
<AssemblyName>OmniSharp.Extensions.LanguageClient.Tests</AssemblyName>
66
<RootNamespace>OmniSharp.Extensions.LanguageServer.Client.Tests</RootNamespace>
77
</PropertyGroup>

test/Dap.Tests/Dap.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.1</TargetFramework>
3+
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
44
<WarningsAsErrors>true</WarningsAsErrors>
55
<PlatformTarget>AnyCPU</PlatformTarget>
66
</PropertyGroup>

test/JsonRpc.Tests/JsonRpc.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.1</TargetFramework>
3+
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
44
<WarningsAsErrors>true</WarningsAsErrors>
55
<PlatformTarget>AnyCPU</PlatformTarget>
66
</PropertyGroup>

test/Lsp.Tests/Integration/ConnectionAndDisconnectionTests.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO.Pipelines;
23
using System.Threading.Tasks;
34
using FluentAssertions;
45
using MediatR;
@@ -15,7 +16,10 @@ namespace Lsp.Tests.Integration
1516
{
1617
public class ConnectionAndDisconnectionTests : LanguageProtocolTestBase
1718
{
18-
public ConnectionAndDisconnectionTests(ITestOutputHelper outputHelper) : base(new JsonRpcTestOptions().ConfigureForXUnit(outputHelper).WithTestTimeout(TimeSpan.FromSeconds(10)))
19+
public ConnectionAndDisconnectionTests(ITestOutputHelper outputHelper) : base(new JsonRpcTestOptions()
20+
.ConfigureForXUnit(outputHelper)
21+
.WithTestTimeout(TimeSpan.FromSeconds(20))
22+
)
1923
{
2024
}
2125

@@ -28,7 +32,7 @@ public async Task Server_Should_Stay_Alive_When_Requests_Throw_An_Exception()
2832
result.Should().BeTrue();
2933

3034
Func<Task> a = () => client.SendRequest("throw").ReturningVoid(CancellationToken);
31-
a.Should().Throw<InternalErrorException>();
35+
await a.Should().ThrowAsync<InternalErrorException>();
3236

3337
result = await client.SendRequest("keepalive").Returning<bool>(CancellationToken);
3438
result.Should().BeTrue();
@@ -43,7 +47,7 @@ public async Task Client_Should_Stay_Alive_When_Requests_Throw_An_Exception()
4347
result.Should().BeTrue();
4448

4549
Func<Task> a = () => server.SendRequest("throw").ReturningVoid(CancellationToken);
46-
a.Should().Throw<InternalErrorException>();
50+
await a.Should().ThrowAsync<InternalErrorException>();
4751

4852
result = await server.SendRequest("keepalive").Returning<bool>(CancellationToken);
4953
result.Should().BeTrue();

test/Lsp.Tests/Integration/DynamicRegistrationTests.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public async Task Should_Register_Dynamically_After_Initialization()
3434

3535
client.ServerSettings.Capabilities.CompletionProvider.Should().BeNull();
3636

37+
await Events.SettleNext();
38+
await Events.SettleNext();
39+
await Events.SettleNext();
3740
await Events.SettleNext();
3841

3942
client.RegistrationManager.CurrentRegistrations.Should().Contain(x =>
@@ -58,7 +61,7 @@ public async Task Should_Register_Dynamically_While_Server_Is_Running()
5861
})
5962
);
6063

61-
await Settle().Take(2);
64+
await Task.Delay(TimeSpan.FromSeconds(1));
6265

6366
client.RegistrationManager.CurrentRegistrations.Should().Contain(x =>
6467
x.Method == TextDocumentNames.Completion && SelectorMatches(x, z=> z.HasLanguage && z.Language == "vb")
@@ -85,7 +88,7 @@ public async Task Should_Unregister_Dynamically_While_Server_Is_Running()
8588

8689
disposable.Dispose();
8790

88-
await Settle().Take(2);
91+
await Task.Delay(TimeSpan.FromSeconds(1));
8992

9093
client.RegistrationManager.CurrentRegistrations.Should().NotContain(x =>
9194
x.Method == TextDocumentNames.Completion && SelectorMatches(x, z=> z.HasLanguage && z.Language == "vb")

test/Lsp.Tests/Lsp.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.1</TargetFramework>
3+
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
44
<WarningsAsErrors>true</WarningsAsErrors>
55
<PlatformTarget>AnyCPU</PlatformTarget>
66
</PropertyGroup>

test/Lsp.Tests/Testing/LanguageServerTestBaseTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public LanguageServerTestBaseTests(ITestOutputHelper testOutputHelper) : base(ne
1919

2020
protected override (Stream clientOutput, Stream serverInput) SetupServer()
2121
{
22-
var clientPipe = new Pipe();
23-
var serverPipe = new Pipe();
22+
var clientPipe = new Pipe(TestOptions.DefaultPipeOptions);
23+
var serverPipe = new Pipe(TestOptions.DefaultPipeOptions);
2424

2525
var server = LanguageServer.PreInit(options => {
2626
options.WithInput(serverPipe.Reader).WithOutput(clientPipe.Writer);

0 commit comments

Comments
 (0)