-
Notifications
You must be signed in to change notification settings - Fork 323
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
Test run parameter added as part of CLI runsettings args #2251
Changes from 7 commits
87e33cc
b1d894b
6b7bd90
84c8c8f
1514575
d9e90f7
561e297
e5f4e7c
68e5412
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CommandLine.Processors | |
using Microsoft.VisualStudio.TestPlatform.Common.Utilities; | ||
|
||
using CommandLineResources = Microsoft.VisualStudio.TestPlatform.CommandLine.Resources.Resources; | ||
using System.Text.RegularExpressions; | ||
|
||
/// <summary> | ||
/// The argument processor for runsettings passed as argument through cli | ||
|
@@ -139,14 +140,22 @@ private void CreateOrOverwriteRunSettings(IRunSettingsProvider runSettingsProvid | |
|
||
for (int index = 0; index < length; index++) | ||
{ | ||
var keyValuePair = args[index]; | ||
var indexOfSeparator = keyValuePair.IndexOf("="); | ||
if (indexOfSeparator <= 0 || indexOfSeparator >= keyValuePair.Length - 1) | ||
var arg = args[index]; | ||
|
||
if (UpdateTestRunParameterNode(runSettingsProvider, arg)) | ||
{ | ||
continue; | ||
} | ||
var key = keyValuePair.Substring(0, indexOfSeparator).Trim(); | ||
var value = keyValuePair.Substring(indexOfSeparator + 1); | ||
|
||
var indexOfSeparator = arg.IndexOf("="); | ||
|
||
if (indexOfSeparator <= 0 || indexOfSeparator >= arg.Length - 1) | ||
{ | ||
continue; | ||
} | ||
|
||
var key = arg.Substring(0, indexOfSeparator).Trim(); | ||
var value = arg.Substring(indexOfSeparator + 1); | ||
|
||
if (string.IsNullOrWhiteSpace(key)) | ||
{ | ||
|
@@ -160,6 +169,25 @@ private void CreateOrOverwriteRunSettings(IRunSettingsProvider runSettingsProvid | |
} | ||
} | ||
|
||
private bool UpdateTestRunParameterNode(IRunSettingsProvider runSettingsProvider, string node) | ||
{ | ||
if (!node.Contains(Constants.TestRunParametersName)) | ||
{ | ||
return false; | ||
} | ||
|
||
var match = runSettingsProvider.GetTestRunParameterNodeMatch(node); | ||
hvinett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (string.Compare(match.Value, node) == 0) | ||
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.
is this case insensitive? 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. No, it is case sensitive. |
||
{ | ||
runSettingsProvider.UpdateTestRunParameterSettingsNode(match); | ||
return true; | ||
} | ||
|
||
var exceptionMessage = string.Format(CommandLineResources.InvalidTestRunParameterArgument, node); | ||
throw new CommandLineException(exceptionMessage); | ||
} | ||
|
||
private void UpdateFrameworkAndPlatform(string key, string value) | ||
{ | ||
if (key.Equals(FrameworkArgumentExecutor.RunSettingsPath)) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
this can throw exception, either catch here, or in the caller.
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.
There are four argument exceptions possible
1.ArgumentOutOfRangeException : This comes if options is not a valid bitwise combination, but we have not given options in match
2.ArgumentNullException : This commes if input or pattern is null, but input is always not null and pattern is not null.
3.RegexMatchTimeoutException :This commes if timout occured,but as Pattern is fixed and we have not set timeout in match. We won't get this exceptions
4.ArgumentException : This comes if regular expression is not syntactically correct,This too not valid in our case..
so catching an exception is not that reasonable