question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug with --disable-mutation-types and --enable-mutation-types

See original GitHub issue

Hi 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:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
DudeNr33commented, Sep 28, 2021

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 to 124. If we don’t have any tests for this, mutmut run will correctly report “1/1 SURVIVED”. But when you then run mutmut show all, it again lists only one surviving mutant, but this time it shows the mutant array["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.

0reactions
DudeNr33commented, Oct 5, 2021

mutmut computes an array of possible mutations for each source code line. The cache stores the line and the index (that is: the index in the array of possible mutations):

class Mutant(db.Entity):
    line = Required(Line)
    index = Required(int)
    tested_against_hash = Optional(str, autostrip=False)
    status = Required(str, autostrip=False)  # really an enum of mutant_statuses

In my original implementation for --enable-mutation-types I returned too early from the mutate_node method and broke this indexing mechanism. With the linked PR mutmut now correctly identifies all possible mutations again, but simply does not perform a mutation if it does not belong to the desired mutation types.

Read more comments on GitHub >

github_iconTop Results From Across the Web

when opting out of mutation, mutation crds should not be created
I'm using the helm value disableMutation=true but still get. ["CustomResourceDefinition" ... Don't install CRDs for mutation types if mutation disabled
Read more >
Mutation, Repair and Recombination - Genomes - NCBI - NIH
(A) A mutation is a small-scale change in the nucleotide sequence of a DNA molecule. A point mutation is shown but there are...
Read more >
Single mutation makes Escherichia coli an insect mutualist
Each mutation reproduced the mutualistic phenotypes when introduced into wild-type E. coli, confirming that single carbon catabolite ...
Read more >
DNA Mutations | Biology for Majors I - Lumen Learning
A mutation is a change that occurs in our DNA sequence, either due to mistakes when the DNA is ... Mutations contribute to...
Read more >
New insights into the generation and role of de novo ...
These state-of-the art genomic approaches allow us to determine additional ... Concisely, each mutation type is a trinucleotide in which the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found