Output verbose logging during tests (#1698)

* Output verbose logging during tests

* fix compile
This commit is contained in:
Charles Gagnon
2022-09-16 16:57:06 -07:00
committed by GitHub
parent 019481e8db
commit 5e0302a95f
3 changed files with 31 additions and 11 deletions

View File

@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
@@ -17,6 +18,7 @@ using Microsoft.SqlTools.ServiceLayer.ObjectExplorer;
using Microsoft.SqlTools.ServiceLayer.QueryExecution;
using Microsoft.SqlTools.ServiceLayer.SqlContext;
using Microsoft.SqlTools.ServiceLayer.Workspace;
using Microsoft.SqlTools.Utility;
using NUnit.Framework;
namespace Microsoft.SqlTools.ServiceLayer.Test.Common
@@ -85,7 +87,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
}
/// <summary>
/// Runs a query by calling the services directly (not using the test driver)
/// Runs a query by calling the services directly (not using the test driver)
/// </summary>
public void RunQuery(TestServerType serverType, string databaseName, string queryText, bool throwOnError = false)
{
@@ -94,7 +96,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
}
/// <summary>
/// Runs a query by calling the services directly (not using the test driver)
/// Runs a query by calling the services directly (not using the test driver)
/// </summary>
public async Task RunQueryAsync(TestServerType serverType, string databaseName, string queryText, bool throwOnError = false)
{
@@ -185,13 +187,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Test.Common
const string hostProfileId = "SQLToolsTestService";
Version hostVersion = new Version(1, 0);
// set up the host details and profile paths
// set up the host details and profile paths
var hostDetails = new HostDetails(hostName, hostProfileId, hostVersion);
SqlToolsContext sqlToolsContext = new SqlToolsContext(hostDetails);
// Initialize the ServiceHost, using a MemoryStream for the output stream so that we don't fill up the logs
// with a bunch of outgoing messages (which aren't used for anything during tests)
ServiceHost serviceHost = HostLoader.CreateAndStartServiceHost(sqlToolsContext, null, new MemoryStream());
// Set up our logger to write to Console for tests to help debug issues
Logger.Initialize(autoFlush: true);
Logger.TracingLevel = System.Diagnostics.SourceLevels.All;
Logger.TraceSource.Listeners.Add(new ConsoleTraceListener());
}
}