You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just got bitten by this behaviour, which was unexpected to me.
go test -run TestFoo/Bar
I expected it to run TestFoo/Bar, but not TestFooOther/Bar.
Instead it runs all tests any tests which start with TestFoo, regardless of subtest name.
In order to make it work as I expected, I need to do:
go test -run 'TestFoo$/Bar'
Given that this is a common thing to want to do, and the regexp $ looks very out of place in the middle of the string, I propose that all the parts of the pattern adjacent to / characters should be anchored, so to get the current behaviour, one would do:
go test -run 'TestFoo.*/Bar'
The sequence of regular expressions implied above would be:
(TestFoo.*)$
^(Bar)
The text was updated successfully, but these errors were encountered:
I too get bitten by this a few times a week. Very rarely do I actually want to do -run 'TestFoo.*/Bar'.
FiloSottile
changed the title
cmd/go: test: use anchored matching inside -run pattern
proposal: cmd/go: use anchored matching inside "go test -run" pattern
Aug 31, 2018
Sorry but I think it's too late to change this. This API is set. In general I treat cmd/go's command-line API the same way we treat package APIs - don't redefine existing behaviors (don't make breaking changes).
I use the substring all the time, as in -run=Foo/Bar.
I'm not sure I understand your point about substrings. What Roger is proposing is that your -run=Foo/Bar would become the old -run=Foo$/^Bar, which would still match our example above.
It's still reasonable if this is rejected as a breaking change, though.
go version go1.11 linux/amd64
I just got bitten by this behaviour, which was unexpected to me.
I expected it to run
TestFoo/Bar
, but notTestFooOther/Bar
.Instead it runs all tests any tests which start with
TestFoo
, regardless of subtest name.In order to make it work as I expected, I need to do:
Given that this is a common thing to want to do, and the regexp
$
looks very out of place in the middle of the string, I propose that all the parts of the pattern adjacent to/
characters should be anchored, so to get the current behaviour, one would do:The sequence of regular expressions implied above would be:
The text was updated successfully, but these errors were encountered: