Skip to content
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

feat: improved query syntax #90

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Xiaoy312
Copy link
Contributor

@Xiaoy312 Xiaoy312 commented Apr 12, 2023

GitHub Issue (If applicable): #89

PR Type

What kind of change does this PR introduce?

  • Feature

What is the new behavior?

new improved query syntax:

  • search terms are separated by space

    c# identifier is quite limited, space is definitely not a valid character, so is minus-sign
    multiple consecutive spaces are treated same as one

  • search terms are case insensitive
  • all search terms are chained with AND logic
  • - can be used before any term for exclusion, effectively filtering them out
  • tags can be used to match certain part of the test: // syntax: tag:match_text

    tag are case insensitive

    • class or c matches the class name
    • method or m matches the method name
    • display_name or d matches the display name in [DataRow] or [DynamicData]
    • full_name or f matches the full name of method
    • params or p matches the parameters of [DataRow] or [DynamicData](unrolled)
    • at or @ (without colon) matches the [DataRow] or [DynamicData] case at specific index (DynamicData: index within the source)
  • within a tag, , can be used to specify multiple potential matches (chained by OR logic)

    eg: @0,1,2 or at:0,1,2 // matches 0st, 1nd, 2rd [DataRow] or entry within [DynamicData]

  • match text can be double-quoted to contain spaces, and use \" to escape double-quote within a double-quoted match text:

    eg: p:"1,\"args 2\",3"

  • use ^ and $ to perform head or tail match, or both to perform full match

    eg: c:^List m:Changed$ d:^exactly_this_text$

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Docs have been added/updated which fit documentation template. (for bug fixes / features)
  • Unit Tests and/or UI Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Wasm UI Tests are not showing unexpected any differences. Validate PR Screenshots Compare Test Run results.
  • Contains NO breaking changes
  • Updated the Release Notes
  • Associated with an issue (GitHub or internal)

Other information

Currently we can match multiple tests (by OR logics) via ; delimiter. This is no longer supported in the new syntax.

@Xiaoy312 Xiaoy312 requested a review from jeromelaban April 12, 2023 18:00
@Xiaoy312
Copy link
Contributor Author

Xiaoy312 commented Apr 12, 2023

todo:

  • add an entry in the doc
  • fix: tag-less term logics
  • ~~``allow ; within trimmed term text to act like old impl
    ^ changed to `,`

@Xiaoy312 Xiaoy312 force-pushed the dev/xygu/20230412/improve-query-filter branch 3 times, most recently from f2516c1 to 8ce91be Compare April 14, 2023 10:09
@Xiaoy312 Xiaoy312 force-pushed the dev/xygu/20230412/improve-query-filter branch from 8ce91be to a3d454f Compare May 14, 2023 22:39
@Xiaoy312 Xiaoy312 added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 15, 2023
@Xiaoy312 Xiaoy312 force-pushed the dev/xygu/20230412/improve-query-filter branch from e4d8bb3 to 4b37deb Compare May 15, 2023 20:13
@Xiaoy312 Xiaoy312 requested review from agneszitte and kazo0 May 15, 2023 20:44
@Xiaoy312 Xiaoy312 removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 15, 2023
Comment on lines +164 to +174
## Test runner (UnitTestsControl) filtering syntax
- Search terms are separated by space. Multiple consecutive spaces are treated same as one.
- Multiple search terms are chained with AND logic.
- Search terms are case insensitive.
- `-` can be used before any term for exclusion, effectively inverting the results.
- Special tags can be used to match certain part of the test: // syntax: tag:term
- `class` or `c` matches the class name
- `method` or `m` matches the method name
- `displayname` or `d` matches the display name in [DataRow]
- Search term without a prefixing tag will match either of method name or class name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Test runner (UnitTestsControl) filtering syntax
- Search terms are separated by space. Multiple consecutive spaces are treated same as one.
- Multiple search terms are chained with AND logic.
- Search terms are case insensitive.
- `-` can be used before any term for exclusion, effectively inverting the results.
- Special tags can be used to match certain part of the test: // syntax: tag:term
- `class` or `c` matches the class name
- `method` or `m` matches the method name
- `displayname` or `d` matches the display name in [DataRow]
- Search term without a prefixing tag will match either of method name or class name.
## Test runner (UnitTestsControl) filtering syntax
- Search terms are separated by space. Multiple consecutive spaces are treated the same as one.
- Multiple search terms are chained with AND logic.
- Search terms are case insensitive.
- `-` can be used before any term for exclusion, effectively inverting the results.
- Special tags can be used to match certain parts of the test: // syntax: tag:term
- `class` or `c` matches the class name
- `method` or `m` matches the method name
- `displayname` or `d` matches the display name in [DataRow]
- Search term without a prefixing tag will match either method name or class name.

internal static partial class StringExtensions
{
/// <summary>
/// Like <see cref="string.Split(char[])"/>, but allows exception to be made with a Regex pattern.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Like <see cref="string.Split(char[])"/>, but allows exception to be made with a Regex pattern.
/// Like <see cref="string.Split(char[])"/>, but allows exceptions to be made with a Regex pattern.

/// </summary>
/// <param name="input"></param>
/// <param name="separator"></param>
/// <param name="ignoredPattern">segments matched by the regex will not be splited.</param>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <param name="ignoredPattern">segments matched by the regex will not be splited.</param>
/// <param name="ignoredPattern">segments matched by the regex will not be split.</param>

})
.Where(x => filters?.MatchAllOnlyIfValuePresent(KnownTags.Parameters, x.Parameters) ?? true)
.Where(x => filters?.MatchAllOnlyIf(KnownTags.AtIndex, x.IsDataSourced, y => MatchIndex(y, x.Index)) ?? true)
// fixme: DisplayName will also matches parameters
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// fixme: DisplayName will also matches parameters
// fixme: DisplayName will also match the parameters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixme: ?

/// </summary>
/// <param name="tag"></param>
/// <param name="value"></param>
/// <returns>If all 'tag' filters matches the value, or true if the none filters are of 'tag'.</returns>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <returns>If all 'tag' filters matches the value, or true if the none filters are of 'tag'.</returns>
/// <returns>If all 'tag' filters match the value, or true if the none filters are of 'tag'.</returns>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants