-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
--match-contract and --match-test changed to glob pattern #3916
Conversation
71c091c
to
e315634
Compare
refac and fmt
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.
thanks for taking this on.
love the test.
I have some concerns about the leading *
.
Is this now required when trying to match parts of the name?
This would be breaking behavior.
could you provide some examples of how matching will change with this PR?
cli/tests/it/test_cmd.rs
Outdated
@@ -71,8 +70,8 @@ contract Dummy {} | |||
.unwrap(); | |||
|
|||
// set up command | |||
cmd.args(["test", "--match-test", "testA.*", "--no-match-test", "testB.*"]); | |||
cmd.args(["--match-contract", "TestC.*", "--no-match-contract", "TestD.*"]); | |||
cmd.args(["test", "--match-test", "*testA*", "--no-match-test", "*testB*"]); |
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.
is the leading *
now necessary?
Ohh, you are right. It is a silly mistake on my part. I tested without the leading Thank you for your review |
@mds1 wdyt? I think this is an overall improvement but is technically breaking, right? since no more regex. however this is more in line with how other tools do test matching via cli |
I believe people use some regex syntax to exclude stuff, do we still support this here? |
Will look soon! @jatokz Do you mind leaving a comment here with some examples of what works / what doesn't work for each matcher (contract, test, path), compared to what did/didn't work before? From reading the conversation here my main concern would be removing regex support, as I do think that's useful (and have found it useful myself). With good naming conventions + regex it's easy to target only certain test functions during development, so I want to better understand the tradeoffs of this PR |
in this pr, the exclude patterns are also changed to comma separated globs @mds1 sure! made some progress, going to spend some time to try and get a good list |
Thanks king - appreciate the effort |
hope everyone had a good holiday @mds1 I came up with a few examples:
glob =>
glob =>
glob => doesnt seem possible with this lib so would have to do a comma sep list of every combination
glob =>
testFooDooBar - No glob => there are some other globs patterns available here: https://docs.rs/glob/latest/glob/struct.Pattern.html |
Thanks for those comparisons, that was helpful! Seems simple enough of a change UX-wise. In general I think I'm indifferent on globs vs. regex, and since globs can accomplish pretty much the same thing, this lgtm. It may be worth including something similar to those comparisons in the book too, to help users migrate. @gakonst Seems this will be a breaking change that may break some scripts/workflows/CIs, so we should try to communicate this once merged since I suspect these are commonly used features |
SGTM - Can we document these in the book after we merge so that we can point people to a resource to modify their scripts? |
i linked a pr for the book, its kind of minimalist, I can add the regex comparison as well if you think its good |
Yeah would love to get more examples in the book as well now that we're on it - go for it. Lgtm pending @mds1 approval |
I haven’t tested the PR or reviewed the code (prob won’t be able to until after the holidays) but conceptually it lgtm! |
@mds1 LMK when you get a chance to try! |
Testing with
|
|
Update on 1) from testing on my machine, since I am using a bash shell the test* was being changed to test because it functioned like a glob in my shell and there was a test directory so it matched to that. One way to verify that this is true for you also is to do It seems that will introduce a new issue that does not occur with regex? I'm open to any additional changes that could improve further. |
Would like to get this in a place where it doesn't require quotes or escapes, like it is currently..Can we not parse it as String from CLI, and bring it in the right form/global format internally? |
Is this PR still desired? Personally I prefer the regex pattern as it is much more expressive Moving this outside of the |
I'd be ok closing this, since I haven't seen any complaints about the current behavior |
Motivation
Closes #1230
Solution
Patterns take a comma separated string which converts to a vector of globs. Jaro Winkler got lowered a little because glob symbols mess with prefix.
edit: I rebased a few times so its cleaner when it gets reviewed the first time, i did some refactoring.