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

Plugin hook to filter/select AST nodes for mutation #1681

Closed
apalaniuk opened this issue Aug 15, 2019 · 4 comments
Closed

Plugin hook to filter/select AST nodes for mutation #1681

apalaniuk opened this issue Aug 15, 2019 · 4 comments
Labels
🚀 Feature request New feature request ☠ stale Marked as stale by the stale bot, will be removed after a certain time.

Comments

@apalaniuk
Copy link
Contributor

apalaniuk commented Aug 15, 2019

Currently, entire files have mutations applied to them. #1660/#1472 will allow inline disabling of mutations, but a programmatic approach of selecting which AST nodes to forward for mutation (eg. via a plugin hook) could allow mutation testing more easily in other workflows; for instance, only applying mutations to lines in a VCS diff, which can make it more possible, in certain circumstances, to run as part of standard PRs. This could be especially true when using TypeScript (which I am).

It's trivial to do this at the file level through scripting, but this may not always be granular enough. The above example case is simplified, as there are additional complications, but externalizing it would allow the user to make those decisions, without committing to any approaches in core. As I imagine it, it could be done well in advance of mutation switching, which would also provide some benefits along the same lines, but I don't believe would obviate this approach.

In addition to some comments in the above issues/PRs, #1464 looks like it proposed something similar, so it seems there's some existing interest along these lines.

@apalaniuk apalaniuk added the 🚀 Feature request New feature request label Aug 15, 2019
@apalaniuk apalaniuk changed the title Plugin hook to filter/select AST nodes Plugin hook to filter/select AST nodes for mutation Aug 15, 2019
@bartekleon
Copy link
Member

@apalaniuk you can provide some easier explanation, give a better example? I could implement this idea, but honestly, your "story" was too long for me to fully understand :x
We could work on it since 22.08, due to my holidays right now.

@apalaniuk
Copy link
Contributor Author

apalaniuk commented Aug 15, 2019

No problem.

Allowing users to programmatically select which code is mutated would allow for more flexibility than current inline approaches (#1472) or proposed future config-based approaches.

The context, since this seems to have been suggested in the past (eg. #1464, or this comment) but dropped in favour of other approaches, is that I'd like to mutate arbitrary subsets of code (eg. based on specific lines in git diffs, or based on other properties of the code), which I think can best/only be done programmatically.

I won't prescribe a specific implementation, but I would think allowing users to write plugin implementations for node selection would be straightforward.

I have no problem with implementing it myself, but wanted to get agreement on the approach first.

@jtlimo
Copy link

jtlimo commented May 11, 2020

Hi @apalaniuk and @kmdrGroch; I'm reading this paper about mutation tests, and I really appreciate if it's possible to do this! Introduce mutation tests at diff on PR's.
They are implemented or thinking to do that, I can help.

@stale
Copy link

stale bot commented May 12, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the ☠ stale Marked as stale by the stale bot, will be removed after a certain time. label May 12, 2021
@stale stale bot closed this as completed Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Feature request New feature request ☠ stale Marked as stale by the stale bot, will be removed after a certain time.
Projects
None yet
Development

No branches or pull requests

3 participants