Skip to content

Commit f497d65

Browse files
committed
Cannot use full assembly path as dictionary key for execution options lookup, since .NET Core only passes the filename w/o path
1 parent c2f2d47 commit f497d65

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/xunit.runner.utility/Reporters/DefaultRunnerReporterMessageHandler.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public DefaultRunnerReporterMessageHandler(IRunnerLogger logger)
4040
void AddExecutionOptions(string assemblyFilename, ITestFrameworkExecutionOptions executionOptions)
4141
{
4242
using (ReaderWriterLockWrapper.WriteLock())
43-
executionOptionsByAssembly[assemblyFilename] = executionOptions;
43+
executionOptionsByAssembly[Path.GetFileNameWithoutExtension(assemblyFilename)] = executionOptions;
4444
}
4545

4646
/// <summary>
@@ -87,7 +87,7 @@ protected ITestFrameworkExecutionOptions GetExecutionOptions(string assemblyFile
8787
ITestFrameworkExecutionOptions result;
8888

8989
using (ReaderWriterLockWrapper.ReadLock())
90-
if (!executionOptionsByAssembly.TryGetValue(assemblyFilename, out result))
90+
if (!executionOptionsByAssembly.TryGetValue(Path.GetFileNameWithoutExtension(assemblyFilename), out result))
9191
result = defaultExecutionOptions;
9292

9393
return result;
@@ -149,7 +149,7 @@ protected virtual void LogOutput(StackFrameInfo frameInfo, string output)
149149
void RemoveExecutionOptions(string assemblyFilename)
150150
{
151151
using (ReaderWriterLockWrapper.WriteLock())
152-
executionOptionsByAssembly.Remove(assemblyFilename);
152+
executionOptionsByAssembly.Remove(Path.GetFileNameWithoutExtension(assemblyFilename));
153153
}
154154

155155
/// <inheritdoc/>

src/xunit.runner.utility/Reporters/DefaultRunnerReporterWithTypesMessageHandler.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public DefaultRunnerReporterWithTypesMessageHandler(IRunnerLogger logger)
5858
void AddExecutionOptions(string assemblyFilename, ITestFrameworkExecutionOptions executionOptions)
5959
{
6060
using (ReaderWriterLockWrapper.WriteLock())
61-
executionOptionsByAssembly[assemblyFilename] = executionOptions;
61+
executionOptionsByAssembly[Path.GetFileNameWithoutExtension(assemblyFilename)] = executionOptions;
6262
}
6363

6464
/// <summary>
@@ -101,7 +101,7 @@ protected ITestFrameworkExecutionOptions GetExecutionOptions(string assemblyFile
101101
ITestFrameworkExecutionOptions result;
102102

103103
using (ReaderWriterLockWrapper.ReadLock())
104-
if (!executionOptionsByAssembly.TryGetValue(assemblyFilename, out result))
104+
if (!executionOptionsByAssembly.TryGetValue(Path.GetFileNameWithoutExtension(assemblyFilename), out result))
105105
result = defaultExecutionOptions;
106106

107107
return result;
@@ -163,7 +163,7 @@ protected virtual void LogOutput(StackFrameInfo frameInfo, string output)
163163
void RemoveExecutionOptions(string assemblyFilename)
164164
{
165165
using (ReaderWriterLockWrapper.WriteLock())
166-
executionOptionsByAssembly.Remove(assemblyFilename);
166+
executionOptionsByAssembly.Remove(Path.GetFileNameWithoutExtension(assemblyFilename));
167167
}
168168

169169
/// <summary>

test/test.xunit.runner.utility/Extensibility/DefaultRunnerReporterMessageHandlerTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ public class OnMessage_ITestOutput
251251
[Fact]
252252
public void WithoutFlag_LogsNothing()
253253
{
254-
var executionStartingMessage = Mocks.TestAssemblyExecutionStarting(assemblyFilename: "assembly-path", showLiveOutput: false);
255-
var outputMessage = Mocks.TestOutput("assembly-path", "test-name", "This is test output");
254+
var executionStartingMessage = Mocks.TestAssemblyExecutionStarting(assemblyFilename: "/path/to/assembly-path.dll", showLiveOutput: false);
255+
var outputMessage = Mocks.TestOutput("assembly.DLL", "test-name", "This is test output");
256256
var handler = TestableDefaultRunnerReporterMessageHandler.Create();
257257

258258
handler.OnMessage(executionStartingMessage);
@@ -265,8 +265,8 @@ public void WithoutFlag_LogsNothing()
265265
[Fact]
266266
public void WithFlag_LogsOutput()
267267
{
268-
var executionStartingMessage = Mocks.TestAssemblyExecutionStarting(assemblyFilename: "assembly-path", showLiveOutput: true);
269-
var outputMessage = Mocks.TestOutput("assembly-path", "test-name", "This is test output");
268+
var executionStartingMessage = Mocks.TestAssemblyExecutionStarting(assemblyFilename: "/path/to/assembly-path.dll", showLiveOutput: true);
269+
var outputMessage = Mocks.TestOutput("assembly-path.DLL", "test-name", "This is test output");
270270
var handler = TestableDefaultRunnerReporterMessageHandler.Create();
271271

272272
handler.OnMessage(executionStartingMessage);

0 commit comments

Comments
 (0)