-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Reintroduce Regexp mutations #1166
Conversation
af26771
to
5499ad2
Compare
4fd79be
to
2d4281d
Compare
@@ -63,6 +63,8 @@ def body_expression | |||
# | |||
# @return [Array<Parser::AST::Node>] | |||
def body | |||
# TODO: also: kill 0...1 mutation -- how the heck does this happen? | |||
# manually inserting it causes unit tests to fail. | |||
children.slice(0...-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.
@mbj This is the mysterious mutation that fails the unit tests if you actually insert it:
def body
- children.slice(0...-1)
+ children.slice(0...1)
end
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.
Must be a test selection issue. Very likely the examples from the meta are tagged :regexp
and mutants test selection overwrite does not catch the various regexp subtypes.
I can look into providing a better selection hint.
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.
@dgollahon Is that still a problem?
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.
Yeah, last I checked. If you have any suggestions here i'd appreciate it.
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.
Oh, and another thing with this method @mbj: It fails with multiple mutations on 2.7 but only one on 2.6. I believe that's because of beginless ranges in 2.7. What's our policy for working around that? I could lift the range to a constant or add an --ignore-subject
. That would also resolve this other mutation but I'm not sure if that's what you'd like me to do.
Also, I was wondering: is there a reason we don't check mutation coverage on 2.5?
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.
@dgollahon Lets go with ignore subject for the moment.
I'll produce a version target soon.
require 'mutant/ast/regexp/transformer/quantifier' | ||
require 'mutant/ast/regexp/transformer/recursive' | ||
require 'mutant/ast/regexp/transformer/root' | ||
require 'mutant/ast/regexp/transformer/text' |
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.
I'd love if we could get this into upstream. Having an immutable AST is a much better interface than their mutable one.
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.
Yeah, we may want to open an issue and discuss with the maintainers. I suspect we need changes here or upstream before we can use 2.0.
d049f9d
to
89b92f3
Compare
@dgollahon The only thing I'm concerned about is:
Which means that as soon rubocop moves to 2.x only, which will happen in the future mutant has to catch up to 2.x ASAP. rubocops userbase is much bigger than mutants. Do you have any idea about rubocops plans on 2.x only API usage? Can you elaborate what the 2.x challenge for |
147e608
to
460dcdc
Compare
Right. I don't have any specific intel on this. I doubt it would be immediately but they will probably want to upgrade in the relatively near future since there are now a few bugfixes in 2.x that I expect they would want as well. That said, they already allow 2.x so I'm not sure how eager they are to restrict the 1.x series or not.
I need to go back and look into this in more detail now that I have everything else working (minus that mutation) but several things broke when I upgraded and it all seemed to be around mutability that Is upgrading to 2.x a merge blocker? Or should we get this shipped and then try to make our way to 2.x within the next month or two or so? I was thinking more towards the second option but we can wait until I figure out the 2.x challenges if you want--it will just delay the feature (maybe be a small amount or maybe by a significant amount--I won't know until I invest more time exploring it). |
No, I mostly want to be able to quantify the risk. And ideally have issues open in |
@mbj I figured out what changed and went wrong. See the second commit. I included a monkeypatch to show one possible way it could be fixed (but obviously will remove that). I suppose I will send a PR to |
40a7954
to
ef82da9
Compare
NOTE: I have removed the commit that attempts to upgrade to |
ef82da9
to
460dcdc
Compare
BTW, just as a bit of context around using 2.x: |
@dgollahon It seems that the upstream issue is making good progress. I'd personally try to give it a few days before deciding here. It could be we can depend on 2.x right away. |
460dcdc
to
999fbe0
Compare
@mbj I believe the main outstanding issue is that unusual test selection for that slice mutation but we may want/need to lift the range to a constant or ignore the subject since it would force us to be incompatible with 2.5/2.6 I believe due to beginless range support. I also noticed this in the 2.6 run which was odd:
I am wondering if this is due to the new 3.0 keyword argument parsing/mutating? |
8041f23
to
3b699e6
Compare
@dgollahon This should come back green after a rebase. |
80bc1ca
to
fc3216f
Compare
fc3216f
to
7b95e26
Compare
- Reintroduces regular expression mutations to `mutant` by reverting commit 21d3fef with various improvements and adjustments.
7b95e26
to
a848e48
Compare
This reverts commit 21d3fef.
This was not a clean revert. Note that:
regexp_parser
was 1.3.0, now it is 1.8.2 to accomodate our currentrubocop
version and because there were some relevant bugfixes implemented between 1.3.x and 1.8.x. We should eventually move to 2.0 but it is currently incompatible with this integration. There are some issues with the frozen Regexp classes getting mutated so we may have to open an issue.regexp_parser
becauseregexp_parser
has decided to become more permissive and try to match Ruby's semantics. It was actually very hard to find a case that failed--I brute-forced 50 million regexp strings that had perfect parity of being accepted and then stumbled onto the single hex escape case by accident. See:regexp_parser
rejects/\xA/
but MRI accepts it ammar/regexp_parser#75. This can be removed once we reachregexp_parser
>= 2.0.1.regexp_parser
>= 2.0.1. See: Multi-byte named capture groups do not parse ammar/regexp_parser#76private
.