-
Notifications
You must be signed in to change notification settings - Fork 673
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
Mutation Testing ( splitted into 2 PRs ) #4089
Mutation Testing ( splitted into 2 PRs ) #4089
Conversation
- dockerfile and shell script for specific packages - ci.yml for diff on packages on PR
Fix mutants not being discovered in certain filesSpecific for clarity packageThe cargo-mutants crate believed that due to the name libclarity.rs, the vm module was located within libclarity/vm folder. A fix to this was renaming the file libclarity.rs to mod.rs, and changing the path from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add some documentation on the following:
- What is mutation testing and
mutants
? - How to understand the output
- How to distinguish success from failure, or to know when it's found a problem
I think it should go in docs/testing.md
, but I'm not sure where Jude will want it
Co-authored-by: jbencin <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4089 +/- ##
============================================
+ Coverage 62.42% 82.46% +20.04%
============================================
Files 401 401
Lines 286383 286385 +2
============================================
+ Hits 178775 236169 +57394
+ Misses 107608 50216 -57392 ☔ View full report in Codecov by Sentry. |
- runs for modified files & created files - has to be run before committing the changes ``` cd mutation-testing/scripts sh git-diff.sh ```
To be merged after stacks-network/actions#3 is merged. A new version of cargo mutants was released https://github.com/sourcefrog/cargo-mutants/releases/tag/v23.12.0 and it required a new sync from zero. After the sync is complete, will update the data on the action's repo and merge it. |
@@ -15,7 +15,7 @@ resolver = "2" | |||
|
|||
[lib] | |||
name = "clarity" | |||
path = "./src/libclarity.rs" | |||
path = "./src/lib.rs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without changing this the cargo mutants command would not see the content of the files and call the mutations for them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a bug in cargo-mutants
. I'd open an issue on their GH. It seems related to cargo-mutants
' specific file recognition patterns. Rust typically looks for src/lib.rs
as the main entry point for a crate, so unconventional filenames might not be detected by cargo-mutants
. That's my guess.
I've added some details on this PR and on the PR in the actions repo. As it is completely automated through the CI workflows I think it should be in the actions repo, but I am open to suggestions. Also, not sure how in-depth to go in it as it mostly answers the questions above because of the implementation I've done in order to have straightforward responses based on what was the result of the mutations and also detail which are the functions not tested properly, in case there are. |
- removed only in the new mutants-logger branch
Split this into 2 PRs as one could be merged and would be useful as soon as possible ( the filter one ) and waiting on the other one for the sync to be finished. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Mutation Testing is a technique of evaluating the effectiveness of a series of tests by introducing small changes to the code (mutations) and checking if the tests can detect these small changes.
They are useful because they can show which functions are not tested properly and tell that their tests are missing, timing out or simply those functions are unviable to be tested.
In this PR 2 mutation testing implementations are provided:
filter-pr
which has the role on the**PR**
to run the mutants for the functions highlighted by thegit diff
( functions modified or created ).logger
which has the role of keeping track of all the functions that weren't tested before implementing this. Its final role is to be removed by having complete completion, but till that point, it makes it a lot easier to see which functions need extra tests and add them. On**merge**
, it will run cargo mutants in the same way as the filter-pr and will modify the logged output with the information from the new generated output. (eg. fn A had missing tests before, now it has the tests. it will be removed from missed.txt and appended to caught.txt)Applicable issues
Additional info (benefits, drawbacks, caveats)
Solutions and Recommended Usage
Cargo-mutant does an incremental build for each mutation, that’s why this solution comes with the implementation of tracking the output and only updating it with the differences, to run 10-20 mutants instead of 4000.
CI YML File: Are linked with the actions in the actions' repo stacks-network/actions#3.
Should be executed with every PR, as it tests only the updated or newly added functions in the PR's commits.
How to read the status from the
filter-pr
workflowIf it is not failing, it means all the functions are tested properly.
If it is failing it will display what type of tests are the problem: missing tests, timeout tests, or unviable tests. For each section, it will specify the functions, the files they are in and their line numbers.
Handling Exit Codes (docs)
Mutation testing produces exit codes post-completion.
In the
filter-pr
workflow they are caught and specified with extra details about what should be done based on them.In the
logger
workflow they are updating the place they belong to.Benchmarks
The complete initial sync was tested both on M1 32GB RAM and 64 GB RAM. There were moments when no RAM was left on the 32 one.
There are packages that created problems on
cargo test
on mac os but worked using a docker image with linux. Those are:Checklist