boxed/mutmut

[QUESTION] Is it possible to only generate one mutation per line of code?

Closed this issue · 4 comments

I'm looking to speed up the time to run mutmut. I'm already limiting the mutations to the patch file from a pull request, but I only want to make 1 comment (with 1 mutation result) per line of code. Is it possible to limit mutmut to only generate 1 mutation per line?

Not sure if this is how you'd suggest to do it, but I achieved it doing this in the mutmut_config.py:

lines_mutated = {}

def pre_mutation(context):
    if lines_mutated.get((context.mutation_id.line_number, context.filename)):
        context.skip = True
    lines_mutated[(context.mutation_id.line_number, context.filename)] = True
boxed commented

But... why? Making mutmut faster but not checking stuff doesn't make sense to me. That's not what mutation testing is for.

It's not just about making it faster, it's about not wasting effort. I'm making a tool that comments mutation results on pull requests. Comments are added on the line that was changed if there's a surviving mutation on that line. In this scenario, adding 3 or 4 comments on a single line is overwhelming and unhelpful. And based on findings from this paper, killing one mutation usually kills the surviving mutations from the same line (From the study, mutants are heavily redundant. In more than 90% of cases, adding a test either kills all mutants or none). So in my scenario, I only need to run 1 mutation per changed line of code. It's faster to skip the mutation before running the unit tests than run all mutations and then ignore half of them. The added speed is important since I want to provide feedback on the pull request before it gets merged, no matter how big the pull request.

Hopefully my question makes sense now with that context.

boxed commented

I'm open to a PR that has this feature. But personally I don't agree with the logic. If the code is critical enough to do mutation testing and not just coverage, then any mutant missed could be game over.