Comments (4)
and then running humbug on itself
Because I like seeing mutation testing getting traction in other languages I'd like to share my story on this.
I faced a similar challenge with mutant to run the mutation testing engine for ruby, on itself. The moment the engine gets targeted on itself (or any of its dependencies) the results for killed mutations cannot be trusted anymore. Because you cannot easily decide if:
- A mutation was killed by the test suite
- A mutation was killed by a behavior change before the tests actually ran
Also some mutations led the engine to crash, before the test results could be collected. So instead to fiddle around with this rather fragile situation (it can be mitigated somewhat), to get a decent self hosting I created the "zombie mode":
This mode creates a dynamic in-memory self copy of mutant (and its dependencies) inside another namespace. I do this via tracing the requires, expanding the require against the load path, modifing the AST in-transit to duplicate the require into two semantic effects:
- The normal regular one, as if require would not be hijacked, into the regular
::Mutant
namespace. - A namespaced one to build up a 2nd instance of the mutation testing engine, the so called "zombie", into the
::Zombie::Mutant
namespace. A dependency like::Foo
would move to::Zombie::Foo
.
Than after the engine is loaded I use the API from ::Zombie::Mutant
to kill the mutations in ::Mutant
. As the mutation testing engines code exist 2 times now (including a subset of the dependency tree that works nice with this approach), one side can safely mutate the other side, without the shortcomings of a self hosting mutation testing engine that introduces doubt to the result.
Also I'm now able to test dependencies, like AST transform libraries, unparsers, and other building blocks without that much doubt.
I have no idea if this strategy translates well to this project, but it might help to know about.
This post is naturally only 95% of the story, I omitted some ruby specific details, so feel free to ping me on any question. Happy mutating.
References:
- CLI handling for zombie mode
- Mutant self zombification entry point
- Main Zombification operations
- Small utility to handle details for a specific hijacked require
from humbug.
and then running humbug on itself 😄
from humbug.
Of course ;). Your 85% that is probably over 90% is taunting me :P.
from humbug.
@mbj In very broad strokes, the approach would work in PHP also. The main facet is to basically have two copies of Humbug assigned to different namespaces where one does not impact the other once both are loading into memory. Achieving it in PHP would likely be a bit more ugly owing to how loading classes works in practice, and the difficulties in actually manipulating that dynamically (it boils down to one undocumented file access flag in PHP file streams of all things), but it's certainly doable.
Thanks for dropping by to suggest it!
from humbug.
Related Issues (20)
- Make Humbug tests up and running HOT 3
- Communication channels HOT 8
- Path to PHPUnit not properly escaped HOT 2
- PHPUnit Mock and Prophecy objects shoudn't be mutated HOT 5
- [DISCUSS] Roadmap for Humbug 2.0 HOT 7
- Add behat scenario where there are no tests to run against mutations. HOT 1
- Resolve Appveyor failed builds for PHP 7.0
- PHPUnit Test Listeners are technically read-only (not enforced). We need another means of manipulating suite execution order and suite filtering. HOT 2
- PHAR build error - solution to be documented
- [DISCUSS] Dependency interference/Initial run failures HOT 2
- Make phpdbg a first class citizen HOT 1
- Document whether Humbug runs processes in parallel
- Stripping PHPUnit configuration of elements HOT 3
- Document preferred non-PHAR, non-global installation as using composer-bin to isolate dependencies
- Humbug fails with PHPUnit stderr setting
- Is there a way to configure which PHPUnit test suite to run? HOT 2
- Incompatibility with php-vcr (or other libraries using stream_wrapper_register) HOT 2
- You need to install and enable xdebug in order to.. even with xdebug installed HOT 2
- TImeouts - how to prevent them
- Humbug reports uncovered mutants on a 100% covered codebase HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from humbug.