Skip to content

Commit cdd5f3b

Browse files
Evangelinkbaronfel
authored andcommitted
Cleanup change
1 parent 0368dff commit cdd5f3b

File tree

2 files changed

+9
-28
lines changed

2 files changed

+9
-28
lines changed

src/Cli/dotnet/commands/dotnet-test/Program.cs

+5-20
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private static int ForwardToMsbuild(ParseResult parseResult, string[] args, stri
6868
try
6969
{
7070
Environment.SetEnvironmentVariable(NodeWindowEnvironmentName, "1");
71-
int exitCode = FromParseResult(parseResult, args, settings, testSessionCorrelationId).Execute();
71+
int exitCode = FromParseResult(parseResult, settings, testSessionCorrelationId).Execute();
7272

7373
// We run post processing also if execution is failed for possible partial successful result to post process.
7474
exitCode |= RunArtifactPostProcessingIfNeeded(testSessionCorrelationId, parseResult, FeatureFlag.Instance);
@@ -108,7 +108,7 @@ private static int ForwardToVSTestConsole(ParseResult parseResult, string[] args
108108
return exitCode;
109109
}
110110

111-
private static TestCommand FromParseResult(ParseResult result, string[] args, string[] settings, string testSessionCorrelationId, string msbuildPath = null)
111+
private static TestCommand FromParseResult(ParseResult result, string[] settings, string testSessionCorrelationId, string msbuildPath = null)
112112
{
113113
result.ShowHelpOrErrorIfAppropriate();
114114

@@ -119,6 +119,9 @@ private static TestCommand FromParseResult(ParseResult result, string[] args, st
119119
"-nologo"
120120
};
121121

122+
// Extra msbuild properties won't be parsed and so end up in the UnmatchedTokens list. In addition to those
123+
// properties, all the test settings properties are also considered as unmatched but we don't want to forward
124+
// these as-is to msbuild. So we filter out the test settings properties from the unmatched tokens.
122125
var unMatchedNonSettingsArgs = settings.Length > 1
123126
? result.UnmatchedTokens.TakeWhile(x => x != settings[1])
124127
: result.UnmatchedTokens;
@@ -132,30 +135,12 @@ private static TestCommand FromParseResult(ParseResult result, string[] args, st
132135

133136
if (settings.Any())
134137
{
135-
//workaround for correct -- logic
136-
//var commandArgument = result.GetValueForArgument(TestCommandParser.SlnOrProjectArgument);
137-
//// TODO: @baronfel, @Evangelink
138-
//// If the project or solution is not specified we would expect null here but we actually
139-
//// get some of the parameter (last one before --) instead.
140-
//if (!string.IsNullOrWhiteSpace(commandArgument) && !settings.Contains(commandArgument))
141-
//{
142-
// msbuildArgs.Add(commandArgument);
143-
//}
144-
145138
// skip '--' and escape every \ to be \\ and every " to be \" to survive the next hop
146139
string[] escaped = settings.Skip(1).Select(s => s.Replace("\\", "\\\\").Replace("\"", "\\\"")).ToArray();
147140

148141
string runSettingsArg = string.Join(";", escaped);
149142
msbuildArgs.Add($"-property:VSTestCLIRunSettings=\"{runSettingsArg}\"");
150143
}
151-
else
152-
{
153-
//var argument = result.GetValueForArgument(TestCommandParser.SlnOrProjectArgument);
154-
//if (!string.IsNullOrWhiteSpace(argument))
155-
//{
156-
// msbuildArgs.Add(argument);
157-
//}
158-
}
159144

160145
string verbosityArg = result.ForwardedOptionValues<IReadOnlyCollection<string>>(TestCommandParser.GetCommand(), "verbosity")?.SingleOrDefault() ?? null;
161146
if (verbosityArg != null)

src/Cli/dotnet/commands/dotnet-test/TestCommandParser.cs

+4-8
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ namespace Microsoft.DotNet.Cli
1515
{
1616
internal static class TestCommandParser
1717
{
18-
public static readonly string DocsLink = "https://aka.ms/dotnet-test";
19-
20-
//public static readonly Argument<string> SlnOrProjectArgument = new Argument<string>(CommonLocalizableStrings.SolutionOrProjectArgumentName)
21-
//{
22-
// Description = CommonLocalizableStrings.SolutionOrProjectArgumentDescription,
23-
// Arity = ArgumentArity.ZeroOrOne
24-
//};
18+
public static readonly string DocsLink = "https://aka.ms/dotnet-test";
2519

2620
public static readonly Option<string> SettingsOption = new ForwardedOption<string>(new string[] { "-s", "--settings" }, LocalizableStrings.CmdSettingsDescription)
2721
{
@@ -130,7 +124,9 @@ private static Command ConstructCommand()
130124
{
131125
var command = new DocumentedCommand("test", DocsLink, LocalizableStrings.AppFullName);
132126
command.TreatUnmatchedTokensAsErrors = false;
133-
//command.AddArgument(SlnOrProjectArgument);
127+
128+
// We are on purpose not capturing the solution, project or directory here. We want to pass it to the
129+
// MSBuild command so we are letting it flow.
134130

135131
command.AddOption(SettingsOption);
136132
command.AddOption(ListTestsOption);

0 commit comments

Comments
 (0)