-
Notifications
You must be signed in to change notification settings - Fork 290
Fix DisableAppDomain default value when not running in isolation under VSTest #6900
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
Merged
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8325da1
Initial plan
Copilot 02141f9
Add VSTestConsoleLocator and expand AppDomainTests with vstest.consol…
Copilot b78d4c9
Fix CommandLine usage in AppDomainTests
Copilot 9d894e1
Improve error messages to include stderr in AppDomainTests
Copilot 2f35764
Refactor AppDomainTests to reduce code duplication
Copilot 0e82bc0
Add null check in VSTestConsoleLocator.GetTestPlatformVersion
Copilot 327f5c9
Fix nullable reference warnings in VSTestConsoleLocator
Copilot 19a8212
Fix formatting: remove trailing whitespace in AppDomainTests
Copilot c5759ab
Remove unnecessary Microsoft.TestPlatform package reference
Copilot ae3f00b
Fix
Youssef1313 9171530
Fix formatting
Youssef1313 80a2bfd
Fix
Youssef1313 604f4c1
Fix build error
Youssef1313 de35a2d
Remove unused method
Youssef1313 d99b108
Simplify
Youssef1313 4c3ea5f
Fir formatting
Youssef1313 a63b961
Fix
Youssef1313 0e03e8c
Apply suggestions from code review
Youssef1313 1e9a23a
Address review comments
Youssef1313 4fd8e93
Comment
Youssef1313 65001ad
Fix unused using
Youssef1313 d976cf0
Fix
Youssef1313 08d0abd
Fix
Youssef1313 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
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 |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; | ||
|
|
||
| namespace Microsoft.MSTestV2.CLIAutomation; | ||
|
|
||
| /// <summary> | ||
| /// Helper class to locate vstest.console.exe. | ||
| /// </summary> | ||
| public static class VSTestConsoleLocator | ||
| { | ||
| private const string TestPlatformCLIPackageName = "Microsoft.TestPlatform"; | ||
Youssef1313 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// Gets the path to <c>vstest.console.exe</c>. | ||
| /// </summary> | ||
| /// <returns>Full path to <c>vstest.console.exe</c>.</returns> | ||
| public static string GetConsoleRunnerPath() | ||
| { | ||
| string testPlatformNuGetPackageFolder = Path.Combine( | ||
| GetNugetPackageFolder(), | ||
| TestPlatformCLIPackageName, | ||
Youssef1313 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| GetTestPlatformVersion()); | ||
| if (!Directory.Exists(testPlatformNuGetPackageFolder)) | ||
| { | ||
| throw new DirectoryNotFoundException($"Test platform NuGet package folder '{testPlatformNuGetPackageFolder}' does not exist"); | ||
| } | ||
|
|
||
| string vstestConsolePath = Path.Combine( | ||
| testPlatformNuGetPackageFolder, | ||
| "tools", | ||
| "net462", | ||
nohwnd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "Common7", | ||
| "IDE", | ||
| "Extensions", | ||
| "TestPlatform", | ||
| "vstest.console.exe"); | ||
| return !File.Exists(vstestConsolePath) | ||
| ? throw new InvalidOperationException($"Could not find vstest.console.exe in {vstestConsolePath}") | ||
nohwnd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| : vstestConsolePath; | ||
| } | ||
|
|
||
| private static string GetNugetPackageFolder() | ||
| { | ||
| string? nugetPackagesFolderPath = Environment.GetEnvironmentVariable("NUGET_PACKAGES"); | ||
| if (!string.IsNullOrEmpty(nugetPackagesFolderPath)) | ||
| { | ||
| Assert.IsTrue(Directory.Exists(nugetPackagesFolderPath), $"Found environment variable 'NUGET_PACKAGES' and NuGet package folder '{nugetPackagesFolderPath}' should exist"); | ||
|
|
||
| return nugetPackagesFolderPath; | ||
| } | ||
|
|
||
| string? userProfile = Environment.GetEnvironmentVariable("USERPROFILE"); | ||
| if (string.IsNullOrEmpty(userProfile)) | ||
| { | ||
| throw new InvalidOperationException("USERPROFILE environment variable is not set"); | ||
| } | ||
|
|
||
| nugetPackagesFolderPath = Path.Combine(userProfile, ".nuget", "packages"); | ||
| Assert.IsTrue(Directory.Exists(nugetPackagesFolderPath), $"NuGet package folder '{nugetPackagesFolderPath}' should exist"); | ||
|
|
||
| return nugetPackagesFolderPath; | ||
| } | ||
|
|
||
| private static string GetTestPlatformVersion() | ||
| { | ||
| string cpmFilePath = Path.Combine(GetArtifactsBinFolderPath(), "..", "..", "Directory.Packages.props"); | ||
nohwnd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| using FileStream fileStream = File.OpenRead(cpmFilePath); | ||
| #pragma warning disable CA3075 // Insecure DTD processing in XML | ||
| using var xmlTextReader = new XmlTextReader(fileStream) { Namespaces = false }; | ||
| #pragma warning restore CA3075 // Insecure DTD processing in XML | ||
| var cpmXml = new XmlDocument(); | ||
| cpmXml.Load(xmlTextReader); | ||
|
|
||
| return cpmXml.DocumentElement?.SelectSingleNode("PropertyGroup/MicrosoftNETTestSdkVersion")?.InnerText | ||
| ?? throw new InvalidOperationException($"Could not find MicrosoftNETTestSdkVersion in {cpmFilePath}"); | ||
| } | ||
|
|
||
| private static string GetArtifactsBinFolderPath() | ||
| { | ||
| string assemblyLocation = Assembly.GetExecutingAssembly().Location; | ||
|
|
||
| string artifactsBinFolder = Path.GetFullPath(Path.Combine(assemblyLocation, @"..\..\..\..")); | ||
nohwnd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Assert.IsTrue(Directory.Exists(artifactsBinFolder)); | ||
|
|
||
| return artifactsBinFolder; | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.