-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Handle test parser forwarded args #27961
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
Evangelink
merged 13 commits into
dotnet:release/7.0.1xx
from
baronfel:handle-test-parser-forwarded-args
Nov 10, 2022
+120
−33
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1610dca
Add explicit catch-all argument for forwarded arguments for dotnet test
baronfel b3b5ed7
use unmatched tokens instead
baronfel 226cff0
Add test case for msbuild argument forwarding
baronfel 79a7e31
revert xlf changes because we went with a different strategy
baronfel e853250
Add tests to cover both ways the project-invocation can be tested
baronfel bdbb0f3
fix test args
baronfel 1f0b26a
Apply suggestions from code review
baronfel cf8c7a5
Fix parsing of unhandled arguments
Evangelink 6e1ce52
Remove debugger.launch
Evangelink 0368dff
wip
Evangelink cdd5f3b
Cleanup change
Evangelink 29c336a
Update src/Cli/dotnet/commands/dotnet-test/Program.cs
Evangelink 91c5e63
Apply suggestions from code review
baronfel 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
| using System; | ||
| using System.Collections; | ||
| using System.Reflection; | ||
|
|
||
| namespace TestNamespace | ||
| { | ||
| [TestClass] | ||
| public class Tests | ||
| { | ||
| [TestMethod] | ||
| public void TestMSBuildParameters() | ||
| { | ||
| var assemblyInfoVersion = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion; | ||
| Assert.AreEqual("1.2.3", assemblyInfoVersion); | ||
| } | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/Assets/TestProjects/VSTestMSBuildParameters/VSTestMSBuildParameters.csproj
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,20 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" /> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>$(CurrentTargetFramework)</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="MSTest.TestFramework" Version="$(MSTestVersion)" /> | ||
| <PackageReference Include="MSTest.TestAdapter" Version="$(MSTestVersion)" /> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <!-- Microsoft.NET.Test.Sdk package includes source files which shouldn't be automatically included. --> | ||
| <!-- Excluding those --> | ||
| <Compile Remove="pkgs\Microsoft.NET.Test.Sdk\**" /> | ||
| </ItemGroup> | ||
| </Project> |
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
52 changes: 52 additions & 0 deletions
52
src/Tests/dotnet-test.Tests/GivenDotnetTestContainsMSBuildParameters.cs
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,52 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using Microsoft.DotNet.Tools.Test.Utilities; | ||
| using Xunit; | ||
| using FluentAssertions; | ||
| using Microsoft.DotNet.Cli.Utils; | ||
| using System.IO; | ||
| using System; | ||
| using Microsoft.NET.TestFramework; | ||
| using Microsoft.NET.TestFramework.Assertions; | ||
| using Microsoft.NET.TestFramework.Commands; | ||
| using Xunit.Abstractions; | ||
|
|
||
| namespace Microsoft.DotNet.Cli.Test.Tests | ||
| { | ||
| public class GivenDotnetTestContainsMSBuildParameters : SdkTest | ||
| { | ||
| private const string TestAppName = "VSTestMSBuildParameters"; | ||
| private const string MSBuildParameter = "/p:Version=1.2.3"; | ||
|
|
||
| public GivenDotnetTestContainsMSBuildParameters(ITestOutputHelper log) : base(log) | ||
| { | ||
| } | ||
|
|
||
| [InlineData($"{TestAppName}.csproj")] | ||
| [InlineData(null)] | ||
| [Theory] | ||
| public void ItPassesEnvironmentVariablesFromCommandLineParametersWhenRunningViaCsproj(string projectName) | ||
| { | ||
| var testAsset = _testAssetsManager.CopyTestAsset(TestAppName) | ||
| .WithSource() | ||
| .WithVersionVariables(); | ||
|
|
||
| var testRoot = testAsset.Path; | ||
|
|
||
| CommandResult result = (projectName is null ? new DotnetTestCommand(Log) : new DotnetTestCommand(Log, projectName)) | ||
| .WithWorkingDirectory(testRoot) | ||
| .Execute("--logger", "console;verbosity=detailed", MSBuildParameter); | ||
|
|
||
| if (!TestContext.IsLocalized()) | ||
| { | ||
| result.StdOut | ||
| .Should().Contain("Total tests: 1") | ||
| .And.Contain("Passed: 1") | ||
| .And.Contain("Passed TestMSBuildParameters"); | ||
| } | ||
|
|
||
| result.ExitCode.Should().Be(0); | ||
| } | ||
| } | ||
| } | ||
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.