Skip to content
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

Fixed TRX file overwrite in certain circumstances #2508

Merged
16 commits merged into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
</trans-unit>
</body>
</file>
</xliff>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ internal class TestResult : ITestResult, IXmlTestStore
/// Directory containing the test result files, relative to the root test results directory
/// </summary>
private string relativeTestResultsDirectory;
private readonly TrxFileHelper trxFileHelper;

/// <summary>
/// Paths to test result files, relative to the test results folder, sorted in increasing order
Expand Down Expand Up @@ -270,7 +271,8 @@ public TestResult(
string computerName,
TestOutcome outcome,
TestType testType,
TestListCategoryId testCategoryId)
TestListCategoryId testCategoryId,
TrxFileHelper trxFileHelper)
{
Debug.Assert(computerName != null, "computername is null");
Debug.Assert(!Guid.Empty.Equals(executionId), "ExecutionId is empty");
Expand All @@ -285,6 +287,7 @@ public TestResult(
this.outcome = outcome;
this.categoryId = testCategoryId;
this.relativeTestResultsDirectory = TestRunDirectories.GetRelativeTestResultsDirectory(executionId);
this.trxFileHelper = trxFileHelper;
}

#endregion
Expand Down Expand Up @@ -532,7 +535,7 @@ internal void AddResultFiles(IEnumerable<string> resultFileList)
Debug.Assert(!string.IsNullOrEmpty(resultFile), "'resultFile' is null or empty");
Debug.Assert(resultFile.Trim() == resultFile, "'resultFile' has whitespace at the ends");

this.resultFiles[FileHelper.MakePathRelative(resultFile, testResultsDirectory)] = null;
this.resultFiles[trxFileHelper.MakePathRelative(resultFile, testResultsDirectory)] = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel
{
using System;
using System.Collections.Generic;
using Microsoft.TestPlatform.Extensions.TrxLogger.Utility;
using Microsoft.TestPlatform.Extensions.TrxLogger.XML;

/// <summary>
Expand All @@ -23,7 +24,8 @@ public TestResultAggregation(
string computerName,
TestOutcome outcome,
TestType testType,
TestListCategoryId testCategoryId) : base(runId, testId, executionId, parentExecutionId, resultName, computerName, outcome, testType, testCategoryId) { }
TestListCategoryId testCategoryId,
TrxFileHelper trxFileHelper) : base(runId, testId, executionId, parentExecutionId, resultName, computerName, outcome, testType, testCategoryId, trxFileHelper) { }

/// <summary>
/// Gets the inner results.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal class TestRunConfiguration : IXmlTestStore, IXmlTestStoreCustom

#region Fields
private TestRunConfigurationId id;
private readonly TrxFileHelper trxFileHelper;

[StoreXmlSimpleField(DefaultValue = "")]
private string name;
Expand All @@ -34,14 +35,17 @@ internal class TestRunConfiguration : IXmlTestStore, IXmlTestStoreCustom
/// <param name="name">
/// The name of Run Configuration.
/// </param>
public TestRunConfiguration(string name)
/// <param name="trxFileHelper">
/// InternalFileHelper instance to use in file operations.
/// </param>
internal TestRunConfiguration(string name, TrxFileHelper trxFileHelper)
{
EqtAssert.ParameterNotNull(name, "name");

this.name = name;

this.runDeploymentRoot = string.Empty;
this.id = new TestRunConfigurationId();
this.trxFileHelper = trxFileHelper;
}

#region IXmlTestStoreCustom Members
Expand Down Expand Up @@ -141,7 +145,7 @@ public void Save(XmlElement element, XmlTestStoreParameters parameters)
helper.SaveSimpleField(
element,
"Deployment/@runDeploymentRoot",
FileHelper.MakePathRelative(this.runDeploymentRoot, Path.GetDirectoryName(this.runDeploymentRoot)),
trxFileHelper.MakePathRelative(this.runDeploymentRoot, Path.GetDirectoryName(this.runDeploymentRoot)),
string.Empty);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel
{
using System;
using Microsoft.TestPlatform.Extensions.TrxLogger.Utility;

/// <summary>
/// Class for unit test result.
Expand All @@ -19,6 +20,8 @@ public UnitTestResult(
string computerName,
TestOutcome outcome,
TestType testType,
TestListCategoryId testCategoryId) : base(runId, testId, executionId, parentExecutionId, resultName, computerName, outcome, testType, testCategoryId) { }
TestListCategoryId testCategoryId,
TrxFileHelper trxFileHelper
) : base(runId, testId, executionId, parentExecutionId, resultName, computerName, outcome, testType, testCategoryId, trxFileHelper) { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.TestPlatform.Extensions.TrxLogger.ObjectModel
/// </summary>
internal class UriDataAttachment : IDataAttachment, IXmlTestStore
{
private readonly TrxFileHelper trxFileHelper;
#region Private fields

/// <summary>
Expand All @@ -36,11 +37,14 @@ internal class UriDataAttachment : IDataAttachment, IXmlTestStore
/// </summary>
/// <param name="description">Short description for the attachment</param>
/// <param name="uri">The URI pointing to the resource</param>
/// <param name="trxFileHelper">InternalFileHelper class instance to use in file operations.</param>
/// <exception cref="ArgumentException">'name' is null or empty</exception>
/// <exception cref="ArgumentNullException">'uri' is null</exception>
public UriDataAttachment(string description, Uri uri)
public UriDataAttachment(string description, Uri uri, TrxFileHelper trxFileHelper)
{
this.Initialize(description, uri);
this.trxFileHelper = trxFileHelper;

Initialize(description, uri);
}

#region IDataAttachment Members
Expand Down Expand Up @@ -121,10 +125,10 @@ internal UriDataAttachment Clone(string baseDirectory, bool useAbsoluteUri)
}
else
{
uriToUse = new Uri(FileHelper.MakePathRelative(this.uri.OriginalString, baseDirectory), UriKind.Relative);
uriToUse = new Uri(trxFileHelper.MakePathRelative(this.uri.OriginalString, baseDirectory), UriKind.Relative);
}

return new UriDataAttachment(this.description, uriToUse);
return new UriDataAttachment(this.description, uriToUse, trxFileHelper);
}

// The URI in this instance is already how we want it, and since this class is immutable, no need to clone
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,7 @@ Error Details: {1}:{2}</value>
<data name="PrefixAndNameProvidedError" xml:space="preserve">
<value>The parameters LogFileName and LogFilePrefix cannot be used together. </value>
</data>
<data name="Common_CannotGetNextTimestampFileName" xml:space="preserve">
<value>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">Parametry LogFileName a LogFilePrefix nejde použít společně. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">Die Parameter "LogFileName" und "LogFilePrefix" können nicht zusammen verwendet werden. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">Los parámetros LogFileName y LogFilePrefix no se pueden usar juntos. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">Les paramètres LogFileName et LogFilePrefix ne peuvent pas être utilisés ensemble. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">Non è possibile usare insieme i parametri LogFileName e LogFilePrefix. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">パラメーター LogFileName と LogFilePrefix を同時に使用することはできません。</target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">LogFileName 및 LogFilePrefix 매개 변수는 함께 사용할 수 없습니다. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">Parametry LogFileName i LogFilePrefix nie mogą być używane razem. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">Os parâmetros LogFileName e LogFilePrefix não podem ser usados juntos. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">Параметры LogFileName и LogFilePrefix недопустимо использовать вместе. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">LogFileName ve LogFilePrefix parametreleri birlikte kullanılamaz. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">"{1}" altında "{2}" biçimlendirmesi ve "{0}" ismi kullanılarak müsait bir dosya adı bulunamadı.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ Error Details: {1}:{2}</source>
<target state="new">The parameters LogFileName and LogFilePrefix cannot be given together. </target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">参数 LogFileName 和 LogFilePrefix 不能一起使用。</target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ Fehlerdetails: {1}: {2}</target>
<target state="translated">不能同時使用參數 LogFileName 和 LogFilePrefix。</target>
<note></note>
</trans-unit>
<trans-unit id="Common_CannotGetNextTimestampFileName">
<source>Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</source>
<target state="new">Cannot get find an available filename for {0} using timestamp format '{2}' at {1}.</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Loading