Skip to content

Commit

Permalink
Testhost Diag log file name format change (#303)
Browse files Browse the repository at this point in the history
Update diag log format for testhost. New format ensures log files are unique so that we don't run multiple testhosts with same file name in case of parallel runs.
  • Loading branch information
smadala authored and codito committed Dec 24, 2016
1 parent 78167e9 commit 9a492ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;

using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers;
Expand Down Expand Up @@ -118,7 +119,9 @@ public virtual void Close()

private string GetTimestampedLogFile(string logFile)
{
return Path.ChangeExtension(logFile, "host." + DateTime.Now.ToString("yyMMddhhmmss") + Path.GetExtension(logFile));
return Path.ChangeExtension(logFile,
string.Format("host.{0}_{1}{2}", DateTime.Now.ToString("yy-MM-dd_HH-mm-ss_fffff"),
Thread.CurrentThread.ManagedThreadId, Path.GetExtension(logFile)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace TestPlatform.CrossPlatEngine.UnitTests.Client
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;

using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Interfaces;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client;
Expand Down Expand Up @@ -57,15 +58,17 @@ public void SetupChannelShouldCreateTimestampedLogFileForHost()
{
this.mockRequestSender.Setup(rs => rs.InitializeCommunication()).Returns(123);
EqtTrace.InitializeVerboseTrace("log.txt");

this.testOperationManager.SetupChannel(Enumerable.Empty<string>());

this.mockTestHostManager.Verify(
th =>
th.GetTestHostProcessStartInfo(
It.IsAny<IEnumerable<string>>(),
null,
It.Is<TestRunnerConnectionInfo>(t => t.LogFile.Contains("log.host." + DateTime.Now.ToString("yyMMdd")))));
It.Is<TestRunnerConnectionInfo>(
t => t.LogFile.Contains("log.host." + DateTime.Now.ToString("yy-MM-dd"))
&& t.LogFile.Contains("_" + Thread.CurrentThread.ManagedThreadId + ".txt"))));
EqtTrace.TraceLevel = TraceLevel.Off;
}

Expand Down

0 comments on commit 9a492ea

Please sign in to comment.