-
Notifications
You must be signed in to change notification settings - Fork 336
AnyCPU tests to choose default architecture based on process #2206
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
Merged
vagisha-nidhi
merged 7 commits into
microsoft:master
from
vagisha-nidhi:architechurex86Fixes
Oct 18, 2019
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
85f3219
[Draft] AnyCPU tests to choose default architecture based on process
vagisha-nidhi 29ca150
Cleaning and Addidng Tests
vagisha-nidhi b523963
Addressing review comments
vagisha-nidhi 3b2837a
Removing props file and changed protocol version check
vagisha-nidhi 81aa8ef
Fixing build failure
vagisha-nidhi 0b6a6b3
Using CopyToPublishDIrectory in props file
vagisha-nidhi 5157854
Fixing build scripts
vagisha-nidhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,6 +244,7 @@ public void GetTestHostProcessStartInfoShouldUseTestHostX86ExePresentOnWindows() | |
{ | ||
var testhostExePath = "testhost.x86.exe"; | ||
this.mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(true); | ||
this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); | ||
this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); | ||
|
||
var startInfo = this.GetDefaultStartInfo(); | ||
|
@@ -264,10 +265,11 @@ public void GetTestHostProcessStartInfoShouldUseDotnetExeOnUnix() | |
} | ||
|
||
[TestMethod] | ||
public void GetTestHostProcessStartInfoShouldUseTestHostExeIsPresentOnWindows() | ||
public void GetTestHostProcessStartInfoShouldUseTestHostExeIfPresentOnWindows() | ||
{ | ||
var testhostExePath = "testhost.exe"; | ||
this.mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(true); | ||
this.mockFileHelper.Setup(ph => ph.Exists("testhost.dll")).Returns(true); | ||
this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); | ||
|
||
this.dotnetHostManager.Initialize(this.mockMessageLogger.Object, "<RunSettings><RunConfiguration><TargetPlatform>x64</TargetPlatform></RunConfiguration></RunSettings>"); | ||
|
@@ -276,6 +278,144 @@ public void GetTestHostProcessStartInfoShouldUseTestHostExeIsPresentOnWindows() | |
StringAssert.Contains(startInfo.FileName, testhostExePath); | ||
} | ||
|
||
[TestMethod] | ||
public void GetTestHostProcessStartInfoShouldUseTestHostExeFromNugetIfNotFoundInSourceLocation() | ||
{ | ||
var testhostExePath = "testhost.exe"; | ||
this.dotnetHostManager.Initialize(this.mockMessageLogger.Object, "<RunSettings><RunConfiguration><TargetPlatform>x64</TargetPlatform></RunConfiguration></RunSettings>"); | ||
this.mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(false); | ||
this.mockFileHelper.Setup(ph => ph.Exists("C:\\packages\\microsoft.testplatform.testhost\\15.0.0-Dev\\build\\netcoreapp2.1\\x64\\testhost.exe")).Returns(true); | ||
this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); | ||
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)); | ||
this.mockFileHelper.Setup(ph => ph.GetStream("\\tmp\\test.runtimeconfig.dev.json", FileMode.Open, FileAccess.Read)).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.Read)).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(true); | ||
|
||
var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); | ||
|
||
StringAssert.Contains(startInfo.FileName, "C:\\packages\\microsoft.testplatform.testhost\\15.0.0-Dev\\build\\netcoreapp2.1\\x64\\testhost.exe"); | ||
} | ||
|
||
[TestMethod] | ||
public void GetTestHostProcessStartInfoShouldUseTestHostX86ExeFromNugetIfNotFoundInSourceLocation() | ||
{ | ||
var testhostExePath = "testhost.x86.exe"; | ||
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. See if you can reduce this test by mocking only the relevant call, I am not sure if your change is related to this. |
||
this.dotnetHostManager.Initialize(this.mockMessageLogger.Object, "<RunSettings><RunConfiguration><TargetPlatform>x86</TargetPlatform></RunConfiguration></RunSettings>"); | ||
this.mockFileHelper.Setup(ph => ph.Exists(testhostExePath)).Returns(false); | ||
this.mockFileHelper.Setup(ph => ph.Exists("C:\\packages\\microsoft.testplatform.testhost\\15.0.0-Dev\\build\\netcoreapp2.1\\x86\\testhost.x86.exe")).Returns(true); | ||
this.mockEnvironment.Setup(ev => ev.OperatingSystem).Returns(PlatformOperatingSystem.Windows); | ||
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)); | ||
this.mockFileHelper.Setup(ph => ph.GetStream("\\tmp\\test.runtimeconfig.dev.json", FileMode.Open, FileAccess.Read)).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.Read)).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(true); | ||
|
||
var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo); | ||
|
||
StringAssert.Contains(startInfo.FileName, "C:\\packages\\microsoft.testplatform.testhost\\15.0.0-Dev\\build\\netcoreapp2.1\\x86\\testhost.x86.exe"); | ||
} | ||
|
||
[TestMethod] | ||
public void LaunchTestHostShouldLaunchProcessWithNullEnvironmentVariablesOrArgs() | ||
{ | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
what happens when we give mulitple PlatformTargets
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.
With multiple PlatformTargets, dotnet build generates AnyCPU dll (then picks testhost from nuget path depending upon default architecture)