mutmut icon indicating copy to clipboard operation
mutmut copied to clipboard

Option to do mutations not in place

Open nklapste opened this issue 5 years ago • 7 comments

For safety concerns it could be a good idea to do mutations not in place (e.g. constructing a tempdir with a copy of the source code and temp venv and applying mutants in that cloned enviroment). Maybe some experimentation should be done looking into alternatives for applying mutants?

Having mutmut mutate my working project source code even with version control protections makes me uncomfortable at times.

nklapste avatar Aug 07 '19 22:08 nklapste

Why not clone it to a tempdir then before? :) This also ensures you do not have (un)committed local modifications.

blueyed avatar Aug 07 '19 22:08 blueyed

I agree 100%. I started on trying this but never finished. Don't remember why.

If we fix this it will enable parallel execution too which would be pretty great! (Especially with my as yet unfinished branch that avoids pytest startup time this would be massively faster).

boxed avatar Aug 08 '19 05:08 boxed

I wonder if it is at all possible to do mutations similar to hot patching (i.e. similar to how mocking libraries override functionality). Doing as such would allow for the same virtual environment to be used and disk IO would be kept at a minimum no?

I have no idea if this would yield a real performance gains, or if it is realistically feasible. But, it could be interesting (and clean) to do all mutations within the python run-time/namespace.

nklapste avatar Aug 12 '19 22:08 nklapste

I've looked a bit at this, but it's suuuuuuuper hairy. I don't think it's a good idea.

Looking again at import hooks and forced module reloading seems more worthwhile to me. The latter I already have in a branch and that works fine.

boxed avatar Aug 13 '19 11:08 boxed

@boxed would the hooks and forced module reloading mean mutations aren't done in place and enable parallel execution?

bk521234 avatar Dec 05 '20 19:12 bk521234

I should have commented more here. No the reloading of modules absolutely does not work. It MIGHT work, but that's the same as saying it doesn't work because it can't be trusted. I have a super iffy proof of concept of mutant schemata plus fork workflow with hammett, which seems to work very well but it's a lot of work to get that to production ready.

boxed avatar Dec 06 '20 12:12 boxed

thanks for more info @boxed ! makes sense to me. :+1:

bk521234 avatar Dec 07 '20 02:12 bk521234