-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logger support in run settings #1382
Logger support in run settings #1382
Conversation
…gerInRunSettingsU1 # Conflicts: # test/vstest.console.UnitTests/Processors/RunSpecificTestsArgumentProcessorTests.cs
…mawat23/vstest into loggerInRunSettingsU1
@@ -210,7 +196,7 @@ public bool DiscoverTests(DiscoveryRequestPayload discoveryPayload, ITestDiscove | |||
ex is SettingsException || | |||
ex is InvalidOperationException) | |||
{ | |||
LoggerUtilities.RaiseTestRunError(testLoggerManager, null, ex); | |||
ConsoleLogger.RaiseTestRunError(null, ex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConsoleLogger.RaiseTestRunError(null, ex); [](start = 20, length = 42)
nitpick: can we move this closer to the logger initialization code alone..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified that logger initialization is happening within this block only.
@@ -296,6 +296,13 @@ public static void UpdateTargetPlatform(XmlDocument runSettingsDocument, string | |||
AddNodeIfNotPresent<string>(runSettingsDocument, TargetPlatformNodePath, TargetPlatformNodeName, platform, overwrite); | |||
} | |||
|
|||
public static void UpdateLoggerRunSettings(XmlDocument xmlDocument, string loggerRunSettings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove if not reqd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
var loggerRunSettings = XmlRunSettingsUtilities.GetLoggerRunSettings(runsettingsXml) ?? new LoggerRunSettings(); | ||
var existingLoggerIndex = LoggerUtilities.GetExistingLoggerIndex(ConsoleLogger.FriendlyName, new Uri(ConsoleLogger.ExtensionUri), | ||
loggerRunSettings.LoggerSettingsList); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: loggerRunSettings.GetExistingLoggerIndex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -37,5 +37,7 @@ public interface ITestEngine | |||
/// </summary> | |||
/// <returns>ITestExtensionManager object that helps with extensibility</returns> | |||
ITestExtensionManager GetExtensionManager(); | |||
|
|||
ITestLoggerManager GetLoggerManager(IRequestData requestData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/// <summary> | ||
/// Dispose logger manager. | ||
/// </summary> | ||
void Dispose(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDisposable instead.
/// </summary> | ||
public const string LoggerSettingName = "Logger"; | ||
|
||
/// <summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't similar consts defined for datacollector already ?
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
// ReSharper disable CheckNamespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
}; | ||
} | ||
|
||
// Converting logger cosole params to Configuration element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: console
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -199,6 +243,18 @@ private static void HandleInvalidArgument(string argument) | |||
argument)); | |||
} | |||
|
|||
/// <summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, prefer InheritDoc instead of generic docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
this.testLoggerManager = new TestableTestLoggerManager(); | ||
this.testLoggerManager.AddLogger(this.blameLogger, BlameLogger.ExtensionUri, null); | ||
this.testLoggerManager.EnableLogging(); | ||
// this.testLoggerManager = new TestableTestLoggerManager(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enable these please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -166,10 +166,10 @@ | |||
<value>Error: Invalid operator '{0}'</value> | |||
</data> | |||
<data name="LoggerInitializationError" xml:space="preserve"> | |||
<value>Exception occurred while initializing logger with URI '{0}'. The logger will not be used. Exception: {1}</value> | |||
<value>Exception occurred while initializing logger with {0}: '{1}'. The logger will not be used. Exception: {2}</value> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run build.cmd, then add the other lang changes as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/// <param name="friendlyName"></param> | ||
/// <param name="uri"></param> | ||
/// <param name="loggerSettingsList"></param> | ||
/// <returns></returns> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review docs
this.mockOutput.Verify(o => o.WriteLine("Error123", OutputLevel.Error), Times.Once()); | ||
// this.mockOutput.Verify(o => o.WriteLine("Informational123", OutputLevel.Information), Times.Once()); | ||
// this.mockOutput.Verify(o => o.WriteLine("Warning123", OutputLevel.Warning), Times.Once()); | ||
// this.mockOutput.Verify(o => o.WriteLine("Error123", OutputLevel.Error), Times.Once()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this?
// Assert.ThrowsException<NullReferenceException>(() => | ||
// { | ||
// testRunRequest.Raise(m => m.OnRunStatsChange += null, eventarg); | ||
// }); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.StdOutMessagesBanner, OutputLevel.Information), Times.Once()); | ||
this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once()); | ||
// this.mockOutput.Verify(o => o.WriteLine(CommandLineResources.StdOutMessagesBanner, OutputLevel.Information), Times.Once()); | ||
// this.mockOutput.Verify(o => o.WriteLine(" " + message, OutputLevel.Information), Times.Once()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
/// <returns>ITestLoggerManager object that helps with logger extensibility.</returns> | ||
public ITestLoggerManager GetLoggerManager(IRequestData requestData) | ||
{ | ||
return new TestLoggerManager( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate the data in IRequestData is getting logged properly, even after the request is complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with suggestions
@@ -296,6 +296,13 @@ public static void UpdateTargetPlatform(XmlDocument runSettingsDocument, string | |||
AddNodeIfNotPresent<string>(runSettingsDocument, TargetPlatformNodePath, TargetPlatformNodeName, platform, overwrite); | |||
} | |||
|
|||
public static void UpdateLoggerRunSettings(XmlDocument xmlDocument, string loggerRunSettings) | |||
{ | |||
// TODO: No need for entry here. move to testrequestmanager. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove if not required
{ | ||
if (configurationElement == null) | ||
{ | ||
// There is no configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required here
// Add the logger and if it is a non-existent logger, throw. | ||
var loggerType = | ||
assembly?.GetTypes() | ||
.FirstOrDefault(x => x.AssemblyQualifiedName.Equals(assemblyQualifiedName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put inside try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -45,6 +45,12 @@ public static void AddDefaultRunSettings(this IRunSettingsProvider runSettingsPr | |||
runSettingsProvider.UpdateRunSettings(runSettingsXml); | |||
} | |||
|
|||
public static void UpdateRunSettingsXmlDocumentInnerXml(XmlDocument xmlDocument, string key, string data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove if not required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validated all scenarios and resolved pr comments.
|
Description
Contains following changes:
RFC PR
microsoft/vstest-docs#111