Bug with --disable-mutation-types and --enable-mutation-types
See original GitHub issueHi I have been testing out the new commands since they are quite useful. However I found some bugs related to them.
Here is a testProgram for mutation purpose
def testfunction():
array['a'] = 123
I run this command after building v2.3 mutmut run --enable-mutation-types=number --paths-to-mutate testFunction.py
followed by
mutmut show all
and here is the output:
To apply a mutant on disk:
mutmut apply <id>
To show a mutant:
mutmut show <id>
Survived � (1)
---- testFunction.py (1) ----
# mutant 1
--- testFunction.py
+++ testFunction.py
@@ -1,3 +1,3 @@
def testfunction():
- array['a'] = 123
+ array['XXaXX'] = 123
This seems like a string mutation and not a number mutation, the correct number mutation after taking a brief look at the source code shoule be something like array['a'] = 124
You can get a similar “wrong” output when you run --disable-mutation-types=string
I am not very familar with the code base but I think this bug has something to do with overwriting mutations? see these lines https://github.com/boxed/mutmut/blob/cc7e7825a8a2ca0d5abb5f4748aa8c8ccea7f0f7/mutmut/__init__.py#L629-L643
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top GitHub Comments
Oh, this is really a bug. Thanks @brutalsavage for being the beta tester for this! 😀
mutmut show
shows a completely wrong mutant. Not only that it does not know about the enabled/disabled mutation types - it really shows the wrong mutant, not just one that was not run. In the given example, the only mutant which is performed and run is changing the number to124
. If we don’t have any tests for this,mutmut run
will correctly report “1/1 SURVIVED”. But when you then runmutmut show all
, it again lists only one surviving mutant, but this time it shows the mutantarray["XXaXX"]
. I have to dig deeper how the mutants are cached and identified later on.Putting the value in the config at least does not help with the most recent version where I refactored to Click’s subcommands. I have to double check if this is different for V2.2.0.
mutmut
computes an array of possible mutations for each source code line. The cache stores theline
and theindex
(that is: the index in the array of possible mutations):In my original implementation for
--enable-mutation-types
I returned too early from themutate_node
method and broke this indexing mechanism. With the linked PRmutmut
now correctly identifies all possible mutations again, but simply does not perform a mutation if it does not belong to the desired mutation types.