-
Notifications
You must be signed in to change notification settings - Fork 325
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
Support escaping , in Test filter #1374
Conversation
//todo fix the resource file | ||
this.selectedTestNames = new Collection<string>( | ||
argument.Tokenize(CommandLineResources.SearchStringDelimiter.ToCharArray()[0], '\\') | ||
.Where(x => !string.IsNullOrWhiteSpace(x)) |
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.
remove , from resources
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.
done
We support "," delimiter, are we now supporting "," & "," delimiter? Why do we need to do so? |
|
||
internal static class StringExtensions | ||
{ | ||
public static IEnumerable<string> Tokenize(this string input, char separator, char escape) |
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.
Please add test cases for this class.
Check if input = "\" or "\\" or "\,"
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.
Or make this a private static
method until we need another consumer for this.
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.
Please do not make it private, once you do it, it will forever remain in this dll :(. Please move it to Utilities dll, under String Utilities class
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.
Done
buffer.Append(c); | ||
} | ||
} | ||
if (buffer.Length > 0 || input[input.Length - 1] == separator) yield return buffer.Flush(); |
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.
What happens if buffer length is 0?
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.
it will not flush. that's an empty stringbuilder
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.
You are returning something back if buffer length > 0, what will it return if it is 0? An empty string, null string? If it returns null will the method invoking it crash?
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.
Please check the UTs.
@@ -0,0 +1,46 @@ | |||
// Copyright (c) Microsoft Corporation. All rights reserved. |
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.
Move this class to Testplatfom.Utilities https://github.com/Microsoft/vstest/tree/master/src/Microsoft.TestPlatform.Utilities
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.
Done
@@ -101,6 +101,51 @@ public void CapabilitiesShouldReturnAppropriateProperties() | |||
|
|||
#region RunSpecificTestsArgumentExecutorTests | |||
|
|||
[TestMethod] | |||
public void InitializeShouldThrowIfArguemntIsNull() |
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.
s/Arguemnt/Argument/g
{ | ||
CommandLineOptions.Instance.Reset(); | ||
var testRequestManager = new TestRequestManager(CommandLineOptions.Instance, new TestPlatform(), TestLoggerManager.Instance, TestRunResultAggregator.Instance, this.mockTestPlatformEventSource.Object, this.inferHelper, this.mockMetricsPublisherTask); | ||
var executor = GetExecutor(testRequestManager); |
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.
nit: single blank line between arrange
, act
and assert
== awesome readability :)
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.
noted :)
@@ -328,6 +371,113 @@ public void ExecutorExecuteShouldForValidSourcesAndValidSelectedTestsRunsTestsAn | |||
Assert.AreEqual(ArgumentProcessorResult.Success, argumentProcessorResult); | |||
} | |||
|
|||
[TestMethod] | |||
public void RunTestsWithCommaSeperatedTests() |
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.
nit: naming should follow <UnitOfWork>Should<Behavior>When<Condition>
nit: every test should have only one reason to fail
These two statements will help understand what feature is broken by just looking at the failed test case, adds to productivity.
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.
done
[TestMethod] | ||
public void RunTestsWithFilteredTest() | ||
{ | ||
var mockTestPlatform = new Mock<ITestPlatform>(); |
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.
How do we remove the DRY violations in these tests?
{ | ||
public static IEnumerable<string> Tokenize(this string input, char separator, char escape) | ||
{ | ||
if (input == null) yield break; |
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.
nit: logic should be in separate line within { }
for conditionals. R# with stylecop extension helps catch some of these.
@@ -7,7 +7,7 @@ | |||
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" /> | |||
<PropertyGroup> | |||
<OutputType Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">Exe</OutputType> | |||
<TargetFrameworks>netcoreapp1.0;net451</TargetFrameworks> | |||
<TargetFrameworks>net451;netcoreapp1.0</TargetFrameworks> |
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.
Why do we need this? Revert this
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.
Without this VS is not recognizing tests
} | ||
|
||
[TestMethod] | ||
public void ExecutorShouldSplitTestsSeperatedByComma() |
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.
s/Seperate/Separate : everywhere
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.
fixed
executor.Initialize("Test1, Test2"); | ||
ArgumentProcessorResult argumentProcessorResult = executor.Execute(); | ||
|
||
mockOutput.Verify(o => o.WriteLine(It.IsAny<string>(), OutputLevel.Warning), Times.Never); |
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.
Do we need to check for error as well ?
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.
not required unless we are expecting an error
@@ -83,6 +83,9 @@ internal class RunSpecificTestsArgumentProcessorCapabilities : BaseArgumentProce | |||
|
|||
internal class RunSpecificTestsArgumentExecutor : IArgumentExecutor | |||
{ | |||
public const char SplitDelimeter = ','; |
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.
s/Delimeter/Delimiter : everywhere
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.
Fixed
var argsList = data.Tokenize(SplitChar, EscapeChar); | ||
var enumerable = argsList as string[] ?? argsList.ToArray(); | ||
|
||
Assert.IsTrue(enumerable.Length == 1); |
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.
Should we use SequenceEqual instead or have another assert? just length check isn't good.
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.
Added in the cases where we required.
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
public static class StringExtensions |
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 is already vstest/src/Microsoft.TestPlatform.CoreUtilities/Utilities/StringExtensions.cs
Can we move this there ?
Currently vstest console runner doesn't support escaping of
,
in test filter.This PR adds support of escaping this by adding
\
.