-
Notifications
You must be signed in to change notification settings - Fork 325
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
Enable Trx logger in TPv2 #5
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,14 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.Logging | |
using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Linq; | ||
using Microsoft.VisualStudio.TestPlatform.Common.Utilities; | ||
using CommonResources = Microsoft.VisualStudio.TestPlatform.Common.Resources; | ||
|
||
/// <summary> | ||
|
@@ -52,7 +55,7 @@ internal class TestLoggerManager : ITestDiscoveryEventsRegistrar, ITestRunEvents | |
|
||
private TestLoggerExtensionManager testLoggerExtensionManager; | ||
private IDiscoveryRequest discoveryRequest; | ||
|
||
#endregion | ||
|
||
#region Constructor | ||
|
@@ -157,8 +160,7 @@ public void AddLogger(Uri uri, Dictionary<string, string> parameters) | |
} | ||
else | ||
{ | ||
// todo Read Output Directory from RunSettings | ||
((ITestLogger)logger.Value).Initialize(this.loggerEvents, null); | ||
((ITestLogger)logger.Value).Initialize(this.loggerEvents, this.GetResultsDirectory(RunSettingsManager.Instance.ActiveRunSettings)); | ||
} | ||
} | ||
catch (Exception e) | ||
|
@@ -181,7 +183,7 @@ public void AddLogger(Uri uri, Dictionary<string, string> parameters) | |
uri.OriginalString)); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Tries to get uri of the logger corresponding to the friendly name. If no such logger exists return null. | ||
/// </summary> | ||
|
@@ -203,7 +205,7 @@ public bool TryGetUriFromFriendlyName(string friendlyName, out string loggerUri) | |
loggerUri = null; | ||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// Registers to receive events from the provided test run request. | ||
/// These events will then be broadcast to any registered loggers. | ||
|
@@ -239,7 +241,7 @@ public void RegisterDiscoveryEvents(IDiscoveryRequest discoveryRequest) | |
this.discoveryRequest = discoveryRequest; | ||
discoveryRequest.OnDiscoveryMessage += this.DiscoveryMessageHandler; | ||
} | ||
|
||
/// <summary> | ||
/// Unregisters the events from the test run request. | ||
/// </summary> | ||
|
@@ -253,7 +255,7 @@ public void UnregisterTestRunEvents(ITestRunRequest testRunRequest) | |
testRunRequest.OnRunCompletion -= this.TestRunCompleteHandler; | ||
this.runRequest.DataCollectionMessage -= this.DiscoveryMessageHandler; | ||
} | ||
|
||
/// <summary> | ||
/// Unregister the events from the discovery request. | ||
/// </summary> | ||
|
@@ -341,6 +343,33 @@ protected virtual void Dispose(bool disposing) | |
|
||
#region Private Members | ||
|
||
/// <summary> | ||
/// Gets the test results directory. | ||
/// </summary> | ||
/// <param name="runSettings">Test run settings.</param> | ||
/// <returns>Test results directory</returns> | ||
internal string GetResultsDirectory(RunSettings runSettings) | ||
{ | ||
string resultsDirectory = null; | ||
if (runSettings != null) | ||
{ | ||
try | ||
{ | ||
RunConfiguration runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runSettings.SettingsXml); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RunSettings.GetSettings("RunConfiguration") instead. This is already parsed. [Faahmad] RunSettings.GetSettings("RunConfiguration") will give you an object of ISettingsProvider. This is not what we want. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RunconfigurationSettingsProvider is what you would get. There is a property in RunConfigurationSettingsProvider which gets you the RunConfiguration. You can just add a utility function that does this for you if you want. |
||
resultsDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfiguration); | ||
} | ||
catch (SettingsException se) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When would this be thrown? I'm guessing you dont need this once you change the above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are going through XmlRunSettingsUtilities.GetRunConfigurationNode for now, we can get above exception. |
||
{ | ||
if (EqtTrace.IsErrorEnabled) | ||
{ | ||
EqtTrace.Error("TestLoggerManager.GetResultsDirectory: Unable to get the test results directory: Error {0}", se); | ||
} | ||
} | ||
} | ||
|
||
return resultsDirectory; | ||
} | ||
|
||
/// <summary> | ||
/// Populates user supplied and default logger parameters. | ||
/// </summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@IF NOT DEFINED _ECHO @ECHO OFF | ||
|
||
@ECHO. | ||
|
||
SET TPBINRELPATH=..\\..\\artifacts\\src\\Microsoft.TestPlatform.VSIXCreator\\bin\\Release | ||
|
||
IF EXIST "%TPBINRELPATH%" ( | ||
IF EXIST "%TPBINRELPATH%\\net461\\win7-x64\\Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.dll" ( | ||
MOVE /Y "%TPBINRELPATH%\\net461\\win7-x64\\Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.dll" "%TPBINRELPATH%\\net461\\win7-x64\\Extensions" | ||
) | ||
) | ||
|
||
SET TPBINDEBUGPATH=..\\..\\artifacts\\src\\Microsoft.TestPlatform.VSIXCreator\\bin\\Debug | ||
|
||
IF EXIST "%TPBINDEBUGPATH%" ( | ||
IF EXIST "%TPBINDEBUGPATH%\\net461\\win7-x64\\Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.dll" ( | ||
MOVE /Y "%TPBINDEBUGPATH%\\net461\\win7-x64\\Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger.dll" "%TPBINDEBUGPATH%\\net461\\win7-x64\\Extensions" | ||
) | ||
) |
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.
shouldn't this just return the default value? Somewhere later I guess we are going to do this. Or are we saying we wont do anything if TestResults directory is not provided?