Skip to content

Commit bcc0324

Browse files
Fix unit test file names in the TestLogs directory (#4649)
1 parent c3e3209 commit bcc0324

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Test/L0/TestHostContext.cs

+13-6
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,21 @@ public TestHostContext(object testClass, [CallerMemberName] string testName = ""
5050
_testName = testName;
5151

5252
// Trim the test assembly's root namespace from the test class's full name.
53-
_suiteName = testClass.GetType().FullName.Substring(
54-
startIndex: typeof(Tests.TestHostContext).FullName.LastIndexOf(nameof(TestHostContext)));
55-
_suiteName = _suiteName.Replace(".", "_");
53+
_suiteName = testClass.GetType().FullName.Replace(
54+
typeof(TestHostContext).Namespace,
55+
string.Empty,
56+
StringComparison.OrdinalIgnoreCase);
57+
58+
if (_suiteName.StartsWith("."))
59+
{
60+
_suiteName = _suiteName[1..];
61+
}
62+
63+
_suiteName = _suiteName.Replace(".", "_", StringComparison.OrdinalIgnoreCase);
5664

5765
// Setup the trace manager.
58-
TraceFileName = Path.Combine(
59-
Path.Combine(TestUtil.GetSrcPath(), "Test", "TestLogs"),
60-
$"trace_{_suiteName}_{_testName}.log");
66+
TraceFileName = Path.Combine(TestUtil.GetSrcPath(), "Test", "TestLogs", $"trace_{_suiteName}_{_testName}.log");
67+
6168
if (File.Exists(TraceFileName))
6269
{
6370
File.Delete(TraceFileName);

0 commit comments

Comments
 (0)