-
Notifications
You must be signed in to change notification settings - Fork 266
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
Work towards supporting tree node filtering in MSTest #4905
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Testing.Platform.Requests; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter; | ||
|
||
namespace Microsoft.Testing.Extensions.VSTestBridge.ObjectModel; | ||
|
||
internal sealed class TreeNodeFilterExpression : ITestCaseFilterExpression | ||
{ | ||
private readonly TreeNodeFilter _treeNodeFilter; | ||
private readonly IEnumerable<string>? _supportedProperties; | ||
Check failure on line 13 in src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/TreeNodeFilterExpression.cs
|
||
private readonly Func<string, TestProperty?> _propertyProvider; | ||
Check failure on line 14 in src/Platform/Microsoft.Testing.Extensions.VSTestBridge/ObjectModel/TreeNodeFilterExpression.cs
|
||
|
||
public TreeNodeFilterExpression(TreeNodeFilter treeNodeFilter, IEnumerable<string>? supportedProperties, Func<string, TestProperty?> propertyProvider) | ||
{ | ||
_treeNodeFilter = treeNodeFilter; | ||
_supportedProperties = supportedProperties; | ||
_propertyProvider = propertyProvider; | ||
} | ||
|
||
public string TestCaseFilterValue => _treeNodeFilter.Filter; | ||
|
||
public bool MatchTestCase(TestCase testCase, Func<string, object?> propertyValueProvider) | ||
{ | ||
// TODO | ||
string assemblyName = Path.GetFileNameWithoutExtension(testCase.Source); | ||
ReadOnlySpan<char> fullyQualifiedName = testCase.FullyQualifiedName.AsSpan(); | ||
|
||
int lastDot = fullyQualifiedName.LastIndexOf('.'); | ||
ReadOnlySpan<char> methodName = fullyQualifiedName.Slice(lastDot + 1); | ||
fullyQualifiedName = fullyQualifiedName.Slice(0, lastDot); | ||
|
||
lastDot = fullyQualifiedName.LastIndexOf('.'); | ||
ReadOnlySpan<char> className = fullyQualifiedName.Slice(lastDot + 1); | ||
fullyQualifiedName = fullyQualifiedName.Slice(0, lastDot); | ||
|
||
ReadOnlySpan<char> @namespace = fullyQualifiedName; | ||
|
||
// TODO: PropertyBag argument | ||
return _treeNodeFilter.MatchesFilter($"/{assemblyName}/{@namespace.ToString()}/{className.ToString()}/{methodName.ToString()}", new()); | ||
} | ||
} |
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.
TODO: We can either say that VSTest's filter and tree node filter are not supported together at the same time, or we can create a new
CompoundTestCaseFilterExpression
which takes the twoITestCaseFilterExpression
and does&&
between them.Putting this comment as a reminder, but let's first finalize something that works first then get back to this.