Skip to content

Commit 07ef2e5

Browse files
CopilotmarcpopMSFT
andcommitted
Resolve merge conflict by adapting to refactored TestCommandDefinition
- TestCommandParser was refactored in main branch with options moved to TestCommandDefinition - Added SelfContainedOption and NoSelfContainedOption to TestCommandDefinition - Added options to both ConfigureVSTestCommand and ConfigureTestingPlatformCommand - Updated all references from TestCommandParser to TestCommandDefinition throughout codebase - Fixed validation in TestCommand and MicrosoftTestingPlatformTestCommand to use TestCommandDefinition Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
1 parent c6fa7f3 commit 07ef2e5

File tree

8 files changed

+421
-371
lines changed

8 files changed

+421
-371
lines changed

src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static BuildOptions GetBuildOptions(ParseResult parseResult)
104104
pathOptions,
105105
parseResult.GetValue(CommonOptions.NoRestoreOption),
106106
parseResult.GetValue(MicrosoftTestingPlatformOptions.NoBuildOption),
107-
parseResult.HasOption(TestCommandParser.VerbosityOption) ? parseResult.GetValue(TestCommandParser.VerbosityOption) : null,
107+
parseResult.HasOption(TestCommandDefinition.VerbosityOption) ? parseResult.GetValue(TestCommandDefinition.VerbosityOption) : null,
108108
parseResult.GetValue(MicrosoftTestingPlatformOptions.NoLaunchProfileOption),
109109
parseResult.GetValue(MicrosoftTestingPlatformOptions.NoLaunchProfileArgumentsOption),
110110
otherArgs,
@@ -124,7 +124,7 @@ private static bool BuildOrRestoreProjectOrSolution(string filePath, BuildOption
124124
msbuildArgs.Add($"-verbosity:quiet");
125125
}
126126

127-
var parsedMSBuildArgs = MSBuildArgs.AnalyzeMSBuildArguments(msbuildArgs, CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, TestCommandParser.MTPTargetOption, TestCommandParser.VerbosityOption, CommonOptions.NoLogoOption());
127+
var parsedMSBuildArgs = MSBuildArgs.AnalyzeMSBuildArguments(msbuildArgs, CommonOptions.PropertiesOption, CommonOptions.RestorePropertiesOption, TestCommandDefinition.MTPTargetOption, TestCommandDefinition.VerbosityOption, CommonOptions.NoLogoOption());
128128

129129
int result = new RestoringCommand(parsedMSBuildArgs, buildOptions.HasNoRestore).Execute();
130130

src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ private int RunInternal(ParseResult parseResult, bool isHelp)
4141
ValidationUtility.ValidateSolutionOrProjectOrDirectoryOrModulesArePassedCorrectly(parseResult);
4242

4343
CommonOptions.ValidateSelfContainedOptions(
44-
parseResult.HasOption(TestCommandParser.SelfContainedOption),
45-
parseResult.HasOption(TestCommandParser.NoSelfContainedOption));
44+
parseResult.HasOption(TestCommandDefinition.SelfContainedOption),
45+
parseResult.HasOption(TestCommandDefinition.NoSelfContainedOption));
4646

4747
int degreeOfParallelism = GetDegreeOfParallelism(parseResult);
4848
var testOptions = new TestOptions(

src/Cli/dotnet/Commands/Test/TestCommandDefinition.cs

Lines changed: 389 additions & 0 deletions
Large diffs are not rendered by default.

src/Cli/dotnet/Commands/Test/TestCommandParser.cs

Lines changed: 13 additions & 352 deletions
Large diffs are not rendered by default.

src/Cli/dotnet/Commands/Test/VSTest/TestCommand.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public static int Run(ParseResult parseResult)
2424
parseResult.HandleDebugSwitch();
2525

2626
CommonOptions.ValidateSelfContainedOptions(
27-
parseResult.HasOption(TestCommandParser.SelfContainedOption),
28-
parseResult.HasOption(TestCommandParser.NoSelfContainedOption));
27+
parseResult.HasOption(TestCommandDefinition.SelfContainedOption),
28+
parseResult.HasOption(TestCommandDefinition.NoSelfContainedOption));
2929

3030
FeatureFlag.Instance.PrintFlagFeatureState();
3131

@@ -237,14 +237,14 @@ private static TestCommand FromParseResult(ParseResult result, string[] settings
237237
msbuildArgs.Add($"-property:VSTestSessionCorrelationId={testSessionCorrelationId}");
238238
}
239239

240-
bool noRestore = result.GetValue(TestCommandParser.NoRestoreOption) || result.GetValue(TestCommandParser.NoBuildOption);
240+
bool noRestore = result.GetValue(TestCommandDefinition.NoRestoreOption) || result.GetValue(TestCommandDefinition.NoBuildOption);
241241

242242
var parsedMSBuildArgs = MSBuildArgs.AnalyzeMSBuildArguments(
243243
msbuildArgs,
244244
CommonOptions.PropertiesOption,
245245
CommonOptions.RestorePropertiesOption,
246-
TestCommandParser.VsTestTargetOption,
247-
TestCommandParser.VerbosityOption,
246+
TestCommandDefinition.VsTestTargetOption,
247+
TestCommandDefinition.VerbosityOption,
248248
CommonOptions.NoLogoOption())
249249
.CloneWithNoLogo(true);
250250

@@ -292,9 +292,9 @@ internal static int RunArtifactPostProcessingIfNeeded(string testSessionCorrelat
292292

293293
var artifactsPostProcessArgs = new List<string> { "--artifactsProcessingMode-postprocess", $"--testSessionCorrelationId:{testSessionCorrelationId}" };
294294

295-
if (parseResult.GetResult(TestCommandParser.DiagOption) is not null)
295+
if (parseResult.GetResult(TestCommandDefinition.DiagOption) is not null)
296296
{
297-
artifactsPostProcessArgs.Add($"--diag:{parseResult.GetValue(TestCommandParser.DiagOption)}");
297+
artifactsPostProcessArgs.Add($"--diag:{parseResult.GetValue(TestCommandDefinition.DiagOption)}");
298298
}
299299

300300
try

src/Cli/dotnet/Extensions/OptionForwardingExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static Option<string> ForwardAsOutputPath(this Option<string> option, str
3030
{
3131
// Not sure if this is necessary, but this is what "dotnet test" previously did and so we are
3232
// preserving the behavior here after refactoring
33-
argVal = TestCommandParser.SurroundWithDoubleQuotes(argVal);
33+
argVal = TestCommandDefinition.SurroundWithDoubleQuotes(argVal);
3434
}
3535
return [
3636
$"--property:{outputPropertyName}={argVal}",

src/Cli/dotnet/Telemetry/TelemetryFilter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ PublishCommandParser.ConfigurationOption ]
118118
(
119119
topLevelCommandName: ["run", "clean", "test"],
120120
optionsToLog: [ RunCommandParser.FrameworkOption, CleanCommandParser.FrameworkOption,
121-
TestCommandParser.FrameworkOption, RunCommandParser.ConfigurationOption, CleanCommandParser.ConfigurationOption,
122-
TestCommandParser.ConfigurationOption ]
121+
TestCommandDefinition.FrameworkOption, RunCommandParser.ConfigurationOption, CleanCommandParser.ConfigurationOption,
122+
TestCommandDefinition.ConfigurationOption ]
123123
),
124124
new TopLevelCommandNameAndOptionToLog
125125
(

test/dotnet.Tests/CommandTests/Test/TestCommandParserTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class TestCommandParserTests
1313
public void SurroundWithDoubleQuotesWithNullThrows()
1414
{
1515
Assert.Throws<ArgumentNullException>(() =>
16-
TestCommandParser.SurroundWithDoubleQuotes(null!));
16+
TestCommandDefinition.SurroundWithDoubleQuotes(null!));
1717
}
1818

1919
[Theory]
@@ -23,7 +23,7 @@ public void SurroundWithDoubleQuotesWithNullThrows()
2323
public void SurroundWithDoubleQuotesWhenAlreadySurroundedDoesNothing(string input)
2424
{
2525
var escapedInput = "\"" + input + "\"";
26-
var result = TestCommandParser.SurroundWithDoubleQuotes(escapedInput);
26+
var result = TestCommandDefinition.SurroundWithDoubleQuotes(escapedInput);
2727
result.Should().Be(escapedInput);
2828
}
2929

@@ -35,7 +35,7 @@ public void SurroundWithDoubleQuotesWhenAlreadySurroundedDoesNothing(string inpu
3535
[InlineData("a\"")]
3636
public void SurroundWithDoubleQuotesWhenNotSurroundedSurrounds(string input)
3737
{
38-
var result = TestCommandParser.SurroundWithDoubleQuotes(input);
38+
var result = TestCommandDefinition.SurroundWithDoubleQuotes(input);
3939
result.Should().Be("\"" + input + "\"");
4040
}
4141

@@ -46,7 +46,7 @@ public void SurroundWithDoubleQuotesWhenNotSurroundedSurrounds(string input)
4646
[InlineData("/\\/\\/\\\\")]
4747
public void SurroundWithDoubleQuotesHandlesCorrectlyEvenCountOfTrailingBackslashes(string input)
4848
{
49-
var result = TestCommandParser.SurroundWithDoubleQuotes(input);
49+
var result = TestCommandDefinition.SurroundWithDoubleQuotes(input);
5050
result.Should().Be("\"" + input + "\"");
5151
}
5252

@@ -57,7 +57,7 @@ public void SurroundWithDoubleQuotesHandlesCorrectlyEvenCountOfTrailingBackslash
5757
[InlineData("/\\/\\/\\")]
5858
public void SurroundWithDoubleQuotesHandlesCorrectlyOddCountOfTrailingBackslashes(string input)
5959
{
60-
var result = TestCommandParser.SurroundWithDoubleQuotes(input);
60+
var result = TestCommandDefinition.SurroundWithDoubleQuotes(input);
6161
result.Should().Be("\"" + input + "\\\"");
6262
}
6363

0 commit comments

Comments
 (0)