-
Notifications
You must be signed in to change notification settings - Fork 323
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
Resolve testhost from source directory if we couldnt resolve it via nuget cache #690
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -425,6 +425,73 @@ public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromDepsFile() | |
Assert.IsTrue(startInfo.Arguments.Contains(testHostFullPath)); | ||
} | ||
|
||
[TestMethod] | ||
public void GetTestHostProcessStartInfoShouldIncludeTestHostPathFromSourceDirectoryIfNugetpathDoesntExist() | ||
{ | ||
// Absolute path to the source directory | ||
var sourcePath = Path.Combine($"{Path.DirectorySeparatorChar}tmp", "test.dll"); | ||
|
||
string runtimeConfigFileContent = | ||
@"{ | ||
""runtimeOptions"": { | ||
""additionalProbingPaths"": [ | ||
""C:\\packages"" | ||
] | ||
} | ||
}"; | ||
|
||
string depsFileContent = | ||
@"{ | ||
""runtimeTarget"": { | ||
""name"": "".NETCoreApp,Version=v1.0"", | ||
""signature"": ""8f25843f8e35a3e80ef4ae98b95117ea5c468b3f"" | ||
}, | ||
""compilationOptions"": {}, | ||
""targets"": { | ||
"".NETCoreApp,Version=v1.0"": { | ||
""microsoft.testplatform.testhost/15.0.0-Dev"": { | ||
""dependencies"": { | ||
""Microsoft.TestPlatform.ObjectModel"": ""15.0.0-Dev"", | ||
""Newtonsoft.Json"": ""9.0.1"" | ||
}, | ||
""runtime"": { | ||
""lib/netstandard1.5/Microsoft.TestPlatform.CommunicationUtilities.dll"": { }, | ||
""lib/netstandard1.5/Microsoft.TestPlatform.CrossPlatEngine.dll"": { }, | ||
""lib/netstandard1.5/Microsoft.VisualStudio.TestPlatform.Common.dll"": { }, | ||
""lib/netstandard1.5/testhost.dll"": { } | ||
} | ||
} | ||
} | ||
}, | ||
""libraries"": { | ||
""microsoft.testplatform.testhost/15.0.0-Dev"": { | ||
""type"": ""package"", | ||
""serviceable"": true, | ||
""sha512"": ""sha512-enO8sZmjbhXOfiZ6hV2ncaknaHnQbrGVsHUJzzu2Dmoh4fHFro4BF1Y4+sb4LOQhu4b3DFYPRj1ncd1RQK6HmQ=="", | ||
""path"": ""microsoft.testplatform.testhost/15.0.0-Dev"", | ||
""hashPath"": ""microsoft.testplatform.testhost.15.0.0-Dev"" | ||
} | ||
} | ||
}"; | ||
|
||
MemoryStream runtimeConfigStream = new MemoryStream(Encoding.UTF8.GetBytes(runtimeConfigFileContent)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cant use using here as these memory stream are getting use in mock |
||
this.mockFileHelper.Setup(ph => ph.GetStream("\\tmp\\test.runtimeconfig.dev.json", FileMode.Open, FileAccess.ReadWrite)).Returns(runtimeConfigStream); | ||
this.mockFileHelper.Setup(ph => ph.Exists("\\tmp\\test.runtimeconfig.dev.json")).Returns(true); | ||
|
||
MemoryStream depsFileStream = new MemoryStream(Encoding.UTF8.GetBytes(depsFileContent)); | ||
this.mockFileHelper.Setup(ph => ph.GetStream("\\tmp\\test.deps.json", FileMode.Open, FileAccess.ReadWrite)).Returns(depsFileStream); | ||
this.mockFileHelper.Setup(ph => ph.Exists("\\tmp\\test.deps.json")).Returns(true); | ||
|
||
string testHostFullPath = @"C:\packages\microsoft.testplatform.testhost/15.0.0-Dev\lib/netstandard1.5/testhost.dll"; | ||
this.mockFileHelper.Setup(ph => ph.Exists(testHostFullPath)).Returns(false); | ||
|
||
string testHostPath = Path.Combine($"{Path.DirectorySeparatorChar}tmp", "testhost.dll"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Reuse class variable declared above: |
||
|
||
var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); | ||
|
||
Assert.IsTrue(startInfo.Arguments.Contains(testHostPath)); | ||
} | ||
|
||
[TestMethod] | ||
public async Task DotNetCoreErrorMessageShouldBeReadAsynchronouslyAsync() | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should handle case if testhost.dll does not exist in sourceDirectory too for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Would this publish the Extensions folder, that has the default extensions here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smadala : We are handling the case if testhost.dll doesn't exist here https://github.com/Microsoft/vstest/blob/master/src/Microsoft.TestPlatform.TestHostProvider/Hosting/DotnetTestHostManager.cs#L243
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AbhitejJohn : very interesting catch 👍 . we are planning to handle thing related to Extension in separate task.