Skip to content

Commit

Permalink
Fix unit test file names in the TestLogs directory (#4649)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanduplenskikh authored Feb 20, 2024
1 parent c3e3209 commit bcc0324
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Test/L0/TestHostContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,21 @@ public TestHostContext(object testClass, [CallerMemberName] string testName = ""
_testName = testName;

// Trim the test assembly's root namespace from the test class's full name.
_suiteName = testClass.GetType().FullName.Substring(
startIndex: typeof(Tests.TestHostContext).FullName.LastIndexOf(nameof(TestHostContext)));
_suiteName = _suiteName.Replace(".", "_");
_suiteName = testClass.GetType().FullName.Replace(
typeof(TestHostContext).Namespace,
string.Empty,
StringComparison.OrdinalIgnoreCase);

if (_suiteName.StartsWith("."))
{
_suiteName = _suiteName[1..];
}

_suiteName = _suiteName.Replace(".", "_", StringComparison.OrdinalIgnoreCase);

// Setup the trace manager.
TraceFileName = Path.Combine(
Path.Combine(TestUtil.GetSrcPath(), "Test", "TestLogs"),
$"trace_{_suiteName}_{_testName}.log");
TraceFileName = Path.Combine(TestUtil.GetSrcPath(), "Test", "TestLogs", $"trace_{_suiteName}_{_testName}.log");

if (File.Exists(TraceFileName))
{
File.Delete(TraceFileName);
Expand Down

0 comments on commit bcc0324

Please sign in to comment.