diff --git a/src/Microsoft.SqlTools.ServiceLayer/Credentials/CredentialService.cs b/src/Microsoft.SqlTools.ServiceLayer/Credentials/CredentialService.cs
index cf4182fc..6cb3644e 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Credentials/CredentialService.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Credentials/CredentialService.cs
@@ -48,7 +48,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
/// Default constructor is private since it's a singleton class
///
private CredentialService()
- : this(null, new LinuxCredentialStore.StoreConfig()
+ : this(null, new StoreConfig()
{ CredentialFolder = DefaultSecretsFolder, CredentialFile = DefaultSecretsFile, IsRelativeToUserHomeDir = true})
{
}
@@ -56,7 +56,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
///
/// Internal for testing purposes only
///
- internal CredentialService(ICredentialStore store, LinuxCredentialStore.StoreConfig config)
+ internal CredentialService(ICredentialStore store, StoreConfig config)
{
this.credStore = store != null ? store : GetStoreForOS(config);
}
@@ -64,12 +64,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
///
/// Internal for testing purposes only
///
- internal static ICredentialStore GetStoreForOS(LinuxCredentialStore.StoreConfig config)
+ internal static ICredentialStore GetStoreForOS(StoreConfig config)
{
if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return new Win32CredentialStore();
}
+#if !WINDOWS_ONLY_BUILD
else if(RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return new OSXCredentialStore();
@@ -78,6 +79,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
{
return new LinuxCredentialStore(config);
}
+#endif
throw new InvalidOperationException("Platform not currently supported");
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/FileTokenStorage.cs b/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/FileTokenStorage.cs
index 756421e4..94bbde62 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/FileTokenStorage.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/FileTokenStorage.cs
@@ -13,6 +13,9 @@ using Newtonsoft.Json;
namespace Microsoft.SqlTools.ServiceLayer.Credentials.Linux
{
+
+#if !WINDOWS_ONLY_BUILD
+
public class FileTokenStorage
{
private const int OwnerAccessMode = 384; // Permission 0600 - owner read/write, nobody else has access
@@ -84,4 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials.Linux
Interop.Sys.ChMod(filePath, OwnerAccessMode);
}
}
+
+#endif
+
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/Interop.Errors.cs b/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/Interop.Errors.cs
index f3b1d5f5..d5668068 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/Interop.Errors.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/Interop.Errors.cs
@@ -8,6 +8,9 @@ using System.Runtime.InteropServices;
namespace Microsoft.SqlTools.ServiceLayer.Credentials
{
+
+#if !WINDOWS_ONLY_BUILD
+
internal static partial class Interop
{
/// Common Unix errno error codes.
@@ -218,4 +221,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
}
}
+#endif
+
}
\ No newline at end of file
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/Interop.Sys.cs b/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/Interop.Sys.cs
index 8777ab0c..95848568 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/Interop.Sys.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/Interop.Sys.cs
@@ -8,6 +8,9 @@ using System.Runtime.InteropServices;
namespace Microsoft.SqlTools.ServiceLayer.Credentials
{
+
+#if !WINDOWS_ONLY_BUILD
+
internal static partial class Interop
{
internal static partial class Sys
@@ -37,6 +40,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials
internal const string SystemNative = "System.Native";
}
}
-
}
+
+#endif
+
}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/LinuxCredentialStore.cs b/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/LinuxCredentialStore.cs
index 93350e83..1009b401 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/LinuxCredentialStore.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Credentials/Linux/LinuxCredentialStore.cs
@@ -3,7 +3,6 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -15,6 +14,18 @@ using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Credentials.Linux
{
+ ///
+ /// Store configuration struct
+ ///
+ internal struct StoreConfig
+ {
+ public string CredentialFolder { get; set; }
+ public string CredentialFile { get; set; }
+ public bool IsRelativeToUserHomeDir { get; set; }
+ }
+
+#if !WINDOWS_ONLY_BUILD
+
///
/// Linux implementation of the credential store.
///
@@ -25,13 +36,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials.Linux
///
internal class LinuxCredentialStore : ICredentialStore
{
- internal struct StoreConfig
- {
- public string CredentialFolder { get; set; }
- public string CredentialFile { get; set; }
- public bool IsRelativeToUserHomeDir { get; set; }
- }
-
private string credentialFolderPath;
private string credentialFileName;
private FileTokenStorage storage;
@@ -228,4 +232,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials.Linux
}
}
}
-}
\ No newline at end of file
+#endif
+
+}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Credentials/OSX/OSXCredentialStore.cs b/src/Microsoft.SqlTools.ServiceLayer/Credentials/OSX/OSXCredentialStore.cs
index 8ea262b3..ff76fd00 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Credentials/OSX/OSXCredentialStore.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/Credentials/OSX/OSXCredentialStore.cs
@@ -10,6 +10,9 @@ using Microsoft.SqlTools.ServiceLayer.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Credentials.OSX
{
+
+#if !WINDOWS_ONLY_BUILD
+
///
/// OSX implementation of the credential store
///
@@ -155,4 +158,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Credentials.OSX
}
}
}
-}
\ No newline at end of file
+
+#endif
+
+}
+
diff --git a/src/Microsoft.SqlTools.ServiceLayer/project.json b/src/Microsoft.SqlTools.ServiceLayer/project.json
index 801d6233..9552464b 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/project.json
+++ b/src/Microsoft.SqlTools.ServiceLayer/project.json
@@ -5,6 +5,16 @@
"debugType": "portable",
"emitEntryPoint": true
},
+ "configurations": {
+ "Integration": {
+ "buildOptions": {
+ "define": [
+ "WINDOWS_ONLY_BUILD"
+ ],
+ "emitEntryPoint": true
+ }
+ }
+ },
"dependencies": {
"Newtonsoft.Json": "9.0.1",
"System.Data.Common": "4.1.0",
diff --git a/test/CodeCoverage/codecoverage.bat b/test/CodeCoverage/codecoverage.bat
index e3a58c5c..f47d2180 100644
--- a/test/CodeCoverage/codecoverage.bat
+++ b/test/CodeCoverage/codecoverage.bat
@@ -17,7 +17,20 @@ dotnet build %WORKINGDIR%..\..\src\Microsoft.SqlTools.ServiceLayer\project.json
REM run the tests through OpenCover and generate a report
dotnet build %WORKINGDIR%..\..\test\Microsoft.SqlTools.ServiceLayer.Test\project.json %DOTNETCONFIG%
-"%WORKINGDIR%packages\OpenCover.4.6.519\tools\OpenCover.Console.exe" -register:user -target:dotnet.exe -targetargs:"test %WORKINGDIR%..\Microsoft.SqlTools.ServiceLayer.Test\project.json %DOTNETCONFIG%" -oldstyle -filter:"+[Microsoft.SqlTools.*]* -[xunit*]*" -output:coverage.xml -searchdirs:%WORKINGDIR%..\Microsoft.SqlTools.ServiceLayer.Test\bin\Debug\netcoreapp1.0
+
+SET SQLTOOLSSERVICE_EXE=%WORKINGDIR%..\..\src\Microsoft.SqlTools.ServiceLayer\bin\Integration\netcoreapp1.0\win7-x64\Microsoft.SqlTools.ServiceLayer.exe
+SET SERVICECODECOVERAGE=TRUE
+SET CODECOVERAGETOOL="%WORKINGDIR%packages\OpenCover.4.6.519\tools\OpenCover.Console.exe"
+SET CODECOVERAGEOUTPUT=coverage.xml
+
+dotnet.exe test %WORKINGDIR%..\Microsoft.SqlTools.ServiceLayer.TestDriver\project.json %DOTNETCONFIG%"
+
+SET SERVICECODECOVERAGE=FALSE
+
+"%WORKINGDIR%packages\OpenCover.4.6.519\tools\OpenCover.Console.exe" -mergeoutput -register:user -target:dotnet.exe -targetargs:"test %WORKINGDIR%..\Microsoft.SqlTools.ServiceLayer.TestDriver\project.json %DOTNETCONFIG%" -oldstyle -filter:"+[Microsoft.SqlTools.*]* -[xunit*]*" -output:coverage.xml -searchdirs:%WORKINGDIR%..\Microsoft.SqlTools.ServiceLayer.TestDriver\bin\Debug\netcoreapp1.0
+
+"%WORKINGDIR%packages\OpenCover.4.6.519\tools\OpenCover.Console.exe" -mergeoutput -register:user -target:dotnet.exe -targetargs:"test %WORKINGDIR%..\Microsoft.SqlTools.ServiceLayer.Test\project.json %DOTNETCONFIG%" -oldstyle -filter:"+[Microsoft.SqlTools.*]* -[xunit*]*" -output:coverage.xml -searchdirs:%WORKINGDIR%..\Microsoft.SqlTools.ServiceLayer.Test\bin\Debug\netcoreapp1.0
+
"%WORKINGDIR%packages\OpenCoverToCoberturaConverter.0.2.4.0\tools\OpenCoverToCoberturaConverter.exe" -input:coverage.xml -output:outputCobertura.xml -sources:%WORKINGDIR%..\..\src\Microsoft.SqlTools.ServiceLayer
"%WORKINGDIR%packages\ReportGenerator.2.4.5.0\tools\ReportGenerator.exe" "-reports:coverage.xml" "-targetdir:%WORKINGDIR%\reports"
diff --git a/test/CodeCoverage/runintegration.bat b/test/CodeCoverage/runintegration.bat
new file mode 100644
index 00000000..e52a5bb5
--- /dev/null
+++ b/test/CodeCoverage/runintegration.bat
@@ -0,0 +1,4 @@
+set DOTNETCONFIG=-c Integration
+
+cmd /c npm install
+gulp
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/Credentials/CredentialServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/Credentials/CredentialServiceTests.cs
index 7adbdebe..d174c48e 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test/Credentials/CredentialServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test/Credentials/CredentialServiceTests.cs
@@ -24,7 +24,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Connection
///
public class CredentialServiceTests : IDisposable
{
- private static readonly LinuxCredentialStore.StoreConfig config = new LinuxCredentialStore.StoreConfig()
+ private static readonly StoreConfig config = new StoreConfig()
{
CredentialFolder = ".testsecrets",
CredentialFile = "sqltestsecrets.json",
@@ -61,6 +61,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Connection
{
credStore.DeletePassword(credentialId);
credStore.DeletePassword(otherCredId);
+
+#if !WINDOWS_ONLY_BUILD
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
string credsFolder = ((LinuxCredentialStore)credStore).CredentialFolderPath;
@@ -69,6 +71,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Connection
Directory.Delete(credsFolder, true);
}
}
+#endif
}
[Fact]
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/Credentials/Linux/LinuxInteropTests.cs b/test/Microsoft.SqlTools.ServiceLayer.Test/Credentials/Linux/LinuxInteropTests.cs
index 1dcff8e6..6d4a234c 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test/Credentials/Linux/LinuxInteropTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test/Credentials/Linux/LinuxInteropTests.cs
@@ -15,23 +15,25 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Credentials
[Fact]
public void GetEUidReturnsInt()
{
+#if !WINDOWS_ONLY_BUILD
TestUtils.RunIfLinux(() =>
{
Assert.NotNull(Interop.Sys.GetEUid());
});
+#endif
}
[Fact]
public void GetHomeDirectoryFromPwFindsHomeDir()
{
-
+#if !WINDOWS_ONLY_BUILD
TestUtils.RunIfLinux(() =>
{
string userDir = LinuxCredentialStore.GetHomeDirectoryFromPw();
Assert.StartsWith("/", userDir);
});
+#endif
}
-
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test/project.json b/test/Microsoft.SqlTools.ServiceLayer.Test/project.json
index be2c5a7b..eff33d27 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.Test/project.json
+++ b/test/Microsoft.SqlTools.ServiceLayer.Test/project.json
@@ -8,7 +8,8 @@
"Integration": {
"buildOptions": {
"define": [
- "LIVE_CONNECTION_TESTS"
+ "LIVE_CONNECTION_TESTS",
+ "WINDOWS_ONLY_BUILD"
]
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs
index 5dd7365a..6351f032 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/ServiceTestDriver.cs
@@ -9,6 +9,7 @@
//
using System;
+using System.IO;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
@@ -22,19 +23,55 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver
///
public class ServiceTestDriver : TestDriverBase
{
+
+ public const string ServiceCodeCoverageEnvironmentVariable = "SERVICECODECOVERAGE";
+
+ public const string CodeCoverageToolEnvironmentVariable = "CODECOVERAGETOOL";
+
+ public const string CodeCoverageOutputEnvironmentVariable = "CODECOVERAGEOUTPUT";
+
///
/// Environment variable that stores the path to the service host executable.
///
public static string ServiceHostEnvironmentVariable
{
get { return "SQLTOOLSSERVICE_EXE"; }
- }
+ }
+
+ public bool IsCoverageRun { get; set; }
public ServiceTestDriver()
{
string serviceHostExecutable = Environment.GetEnvironmentVariable(ServiceHostEnvironmentVariable);
+ string serviceHostArguments = "--enable-logging";
- var clientChannel = new StdioClientChannel(serviceHostExecutable, "--enable-logging");
+ //setup the service host for code coverage if the envvar is enabled
+ if (Environment.GetEnvironmentVariable(ServiceCodeCoverageEnvironmentVariable) == "True")
+ {
+ string coverageToolPath = Environment.GetEnvironmentVariable(CodeCoverageToolEnvironmentVariable);
+ if (!string.IsNullOrWhiteSpace(coverageToolPath))
+ {
+ string serviceHostDirectory = Path.GetDirectoryName(serviceHostExecutable);
+ if (string.IsNullOrWhiteSpace(serviceHostDirectory))
+ {
+ serviceHostDirectory = ".";
+ }
+
+ string coverageOutput = Environment.GetEnvironmentVariable(CodeCoverageOutputEnvironmentVariable);
+ if (string.IsNullOrWhiteSpace(coverageOutput))
+ {
+ coverageOutput = "coverage.xml";
+ }
+
+ serviceHostArguments = "-target:" + serviceHostExecutable + " -targetargs:" + serviceHostArguments
+ + " -register:user -oldstyle -filter:\"+[Microsoft.SqlTools.*]* -[xunit*]*\" -output:" + coverageOutput + " -searchdirs:" + serviceHostDirectory;
+ serviceHostExecutable = coverageToolPath;
+
+ this.IsCoverageRun = true;
+ }
+ }
+
+ this.clientChannel = new StdioClientChannel(serviceHostExecutable, serviceHostArguments);
this.protocolClient = new ProtocolEndpoint(clientChannel, MessageProtocolType.LanguageServer);
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/TestDriverBase.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/TestDriverBase.cs
index 7f86764a..dcc352aa 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/TestDriverBase.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Driver/TestDriverBase.cs
@@ -10,8 +10,10 @@
using System;
using System.Collections.Concurrent;
+using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
+using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Channel;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
using Microsoft.SqlTools.ServiceLayer.Utility;
@@ -24,12 +26,29 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Driver
{
protected ProtocolEndpoint protocolClient;
+ protected StdioClientChannel clientChannel;
+
private ConcurrentDictionary> eventQueuePerType =
new ConcurrentDictionary>();
private ConcurrentDictionary> requestQueuePerType =
new ConcurrentDictionary>();
+ public Process ServiceProcess
+ {
+ get
+ {
+ try
+ {
+ return Process.GetProcessById(clientChannel.ProcessId);
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ }
+
public Task SendRequest(
RequestType requestType,
TParams requestParams)
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Tests/QueryExecutionTests.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Tests/QueryExecutionTests.cs
index f102eea4..f38ee3e9 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Tests/QueryExecutionTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Tests/QueryExecutionTests.cs
@@ -3,8 +3,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
+using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.TestDriver.Utility;
using Xunit;
@@ -16,40 +19,49 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
[Fact]
public async Task TestQueryingAfterCompletionRequests()
{
- string ownerUri = System.IO.Path.GetTempFileName();
- string query = "SELECT * FROM sys.objects";
- List tasks = new List();
+ try
+ {
+ string ownerUri = System.IO.Path.GetTempFileName();
+ string query = "SELECT * FROM sys.objects";
+ List tasks = new List();
- await Connect(ownerUri, ConnectionTestUtils.AzureTestServerConnection);
- Enumerable.Range(0, 10).ToList().ForEach(arg => tasks.Add(RequestCompletion(ownerUri, query, 0, 10)));
- var queryTask = RunQuery(ownerUri, query);
- tasks.Add(queryTask);
- await Task.WhenAll(tasks);
+ await Connect(ownerUri, ConnectionTestUtils.AzureTestServerConnection);
- Assert.NotNull(queryTask.Result);
- Assert.NotNull(queryTask.Result.BatchSummaries);
+
+ Enumerable.Range(0, 10).ToList().ForEach(arg => tasks.Add(RequestCompletion(ownerUri, query, 0, 10)));
+ var queryTask = RunQuery(ownerUri, query);
+ tasks.Add(queryTask);
+ await Task.WhenAll(tasks);
+
+ Assert.NotNull(queryTask.Result);
+ Assert.NotNull(queryTask.Result.BatchSummaries);
- await Connect(ownerUri, ConnectionTestUtils.DataToolsTelemetryAzureConnection);
- tasks.Clear();
- Enumerable.Range(0, 10).ToList().ForEach(arg => tasks.Add(RequestCompletion(ownerUri, query, 0, 10)));
- queryTask = RunQuery(ownerUri, query);
- tasks.Add(queryTask);
- await Task.WhenAll(tasks);
+ await Connect(ownerUri, ConnectionTestUtils.DataToolsTelemetryAzureConnection);
+ tasks.Clear();
+ Enumerable.Range(0, 10).ToList().ForEach(arg => tasks.Add(RequestCompletion(ownerUri, query, 0, 10)));
+ queryTask = RunQuery(ownerUri, query);
+ tasks.Add(queryTask);
+ await Task.WhenAll(tasks);
- Assert.NotNull(queryTask.Result);
- Assert.NotNull(queryTask.Result.BatchSummaries);
+ Assert.NotNull(queryTask.Result);
+ Assert.NotNull(queryTask.Result.BatchSummaries);
- await Connect(ownerUri, ConnectionTestUtils.SqlDataToolsAzureConnection);
- tasks.Clear();
- Enumerable.Range(0, 10).ToList().ForEach(arg => tasks.Add(RequestCompletion(ownerUri, query, 0, 10)));
- queryTask = RunQuery(ownerUri, query);
- tasks.Add(queryTask);
- await Task.WhenAll(tasks);
+ await Connect(ownerUri, ConnectionTestUtils.SqlDataToolsAzureConnection);
+ tasks.Clear();
+ Enumerable.Range(0, 10).ToList().ForEach(arg => tasks.Add(RequestCompletion(ownerUri, query, 0, 10)));
+ queryTask = RunQuery(ownerUri, query);
+ tasks.Add(queryTask);
+ await Task.WhenAll(tasks);
- Assert.NotNull(queryTask.Result);
- Assert.NotNull(queryTask.Result.BatchSummaries);
+ Assert.NotNull(queryTask.Result);
+ Assert.NotNull(queryTask.Result.BatchSummaries);
- await Disconnect(ownerUri);
+ await Disconnect(ownerUri);
+ }
+ finally
+ {
+ WaitForExit();
+ }
}
}
}
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Tests/TestBase.cs b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Tests/TestBase.cs
index 43dd45ca..c0989b55 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Tests/TestBase.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/Tests/TestBase.cs
@@ -4,6 +4,7 @@
//
using System;
+using System.Diagnostics;
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
@@ -18,15 +19,37 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
public class TestBase : IDisposable
{
+ private bool isRunning = false;
+
public TestBase()
{
Driver = new ServiceTestDriver();
Driver.Start().Wait();
+ this.isRunning = true;
}
public void Dispose()
{
- Driver.Stop().Wait();
+ if (this.isRunning)
+ {
+ WaitForExit();
+ }
+ }
+
+ public void WaitForExit()
+ {
+ this.isRunning = false;
+
+ if (!Driver.IsCoverageRun)
+ {
+ Driver.Stop().Wait();
+ }
+ else
+ {
+ var p = Process.Start("taskkill", "/IM Microsoft.SqlTools.ServiceLayer.exe /F");
+ p.WaitForExit();
+ Driver.ServiceProcess?.WaitForExit();
+ }
}
///
@@ -43,9 +66,9 @@ namespace Microsoft.SqlTools.ServiceLayer.TestDriver.Tests
///
/// Request a new connection to be created
///
- /// True if the connection completed successfully
+ /// True if the connection completed successfully
protected async Task Connect(string ownerUri, ConnectParams connectParams)
- {
+ {
connectParams.OwnerUri = ownerUri;
var connectResult = await Driver.SendRequest(ConnectionRequest.Type, connectParams);
if (connectResult)
diff --git a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/project.json b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/project.json
index 15c7d9a2..e7246f8d 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.TestDriver/project.json
+++ b/test/Microsoft.SqlTools.ServiceLayer.TestDriver/project.json
@@ -23,7 +23,7 @@
"imports": [
"dotnet5.4",
"portable-net451+win8"
- ],
+ ]
}
},
"runtimes": {