Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Mutpy functionalities into the project instead of relying on the library #64

Merged
merged 77 commits into from
Jun 21, 2024

Conversation

BergLucas
Copy link
Contributor

Introduction

Hello,

I'm currently doing a master's thesis on improving automatic test generation for Python code that uses C libraries. To do this, I'm using Pynguin as a base and I've tried a few things to improve it.

Problem

While writing some code, I encountered some problems with memory leaks and slowness in the generation of assertions by mutation analysis. While trying to fix this, I noticed that the current integration of MutPy with Pynguin made it quite complicated to fix the problems I have.

Proposed solution

Given that MutPy hasn't been updated for a long time, that the version currently used is a fork and that Pynguin only uses a subset of what's available in MutPy, I thought it might be interesting to integrate the used part of MutPy into Pynguin. Given that this could potentially be interesting even without what I tried for my thesis, I thought that making a pull request to propose the change would be a good idea.

Change summary

To summarise what was done, I first added the original MutPy files that were used in the project and then I gradually modified them to integrate them into the project. I added type hints, specifications and I refactored certain parts of complicated code into more understandable code with better comments. I've tried to make the commits as small as possible each time to make the process that led from the original code to the final code more explicit.

In addition, MutPy tests have been converted from unittest to pytest to ensure that the refactoring didn't create any bugs. During this conversion, some bugs were discovered in MutPy such as the modification of the original AST in the HidingVariableDeletion operator and the generation of several identical mutants in certain cases when several visitor functions are present for the same node. There was also a potential "bug" in Pynguin, as RandomHOMStrategy didn't use Pynguin's random generator, so results could potentially be different even with the same seed.

Conclusion

It's a pretty big pull request, sorry, but there's only a very little Pynguin code that's been modified to better integrate the code from MutPy and to make it easier to extend it (because that's why I did it in the first place) so it shouldn't be too hard to review.

Feel free to ask questions about my implementation choices or to say that you think it's a bad idea.

Have a nice day and thanks for having created Pynguin!

@stephanlukasczyk
Copy link
Member

Hi @BergLucas ,

Thank you for this PR. I'll walk over it next week. One question upfront: did you copy the code from MutPy or did you actually reimplement it? I am asking because of license texts; Pynguin uses MIT but the original code of MutPy uses Apache license, and I am from the top of my head not sure whether this allows a relicensing.

@BergLucas
Copy link
Contributor Author

Hi @stephanlukasczyk,

Damn, I forgot to check the licenses. But yes, I copied the original Mutpy code because I wanted to make sure that the changes I made didn't break Pynguin. I've made a lot of changes to the code but I suppose it's still under the original licence. I could reimplement Mutpy's functionalities from scratch if you think it's interesting, but it'll still look a bit like Mutpy at the end because some mutations are basic and there's not really a way to do them differently from Mutpy.

@stephanlukasczyk
Copy link
Member

No worries @BergLucas . Do you mind to contact me through email? I'd like to setup a call, because I'm highly interested in what your work and plans on Pynguin are about. My work email address can be found from our chair's web page https://www.fim.uni-passau.de/en/chair-for-software-engineering-ii/team

@stephanlukasczyk stephanlukasczyk merged commit 66e712c into se2p:main Jun 21, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants