5
54
Fork
You've already forked blue
4

Adding mutation testing as proof-of-concept #65

Open
opened 2025年08月06日 02:49:15 +02:00 by old · 1 comment
Owner
Copy link

I would like to add support for mutation testing in the Guile test-driver. The big idea is to introduce programming bug, that is something a developer could introduced by accident. For example, ++k instead of k++. Or a - b instread of a + b. Or a = b instead of a == b.

Rust has mutant.rs for that purpose. I think it's a great feature for a test framework and we could provide it from the core Guile test-driver.

Basically, there are multiple ways of doing so. It could be at the bytecode level, or even machine instructions. But since it is possible to modify bindings at runtime in Guile, I think we could achieve mutation of program without restarting and recompiling by just using the blue/debug/advice.scm module.

One type of easy targets are predicates. All procedures in a module ending with ? is designated as a predicate. Such predicate could be rewrite to always return either #t or #f. The idea is run the test-suite to see if one test now failed. If all tests passed, this mutant is probably something we would like to investigate since our tests are not exhaustive enough.

As an example, if you rewrite the string-version=? procedure under blue/utils/version.scm to:

(define string-version=? (const #t))

you will see that all tests passed. It means we are not testing for the #f case!

I don't think we want this for beta release to end users, but we might start making something for our internal usage.

I would like to add support for [mutation testing](https://en.wikipedia.org/wiki/Mutation_testing) in the Guile test-driver. The big idea is to introduce programming bug, that is something a developer could introduced by accident. For example, `++k` instead of `k++`. Or `a - b` instread of `a + b`. Or `a = b` instead of `a == b`. Rust has [mutant.rs](https://mutants.rs/) for that purpose. I think it's a great feature for a test framework and we could provide it from the core Guile test-driver. Basically, there are multiple ways of doing so. It could be at the bytecode level, or even machine instructions. But since it is possible to modify bindings at runtime in Guile, I think we could achieve mutation of program without restarting and recompiling by just using the `blue/debug/advice.scm` module. One type of easy targets are predicates. All procedures in a module ending with `?` is designated as a predicate. Such predicate could be rewrite to always return either `#t` or `#f`. The idea is run the test-suite to see if one test now failed. If all tests passed, this mutant is probably something we would like to investigate since our tests are not exhaustive enough. As an example, if you rewrite the `string-version=?` procedure under `blue/utils/version.scm` to: ```scheme (define string-version=? (const #t)) ``` you will see that all tests passed. It means we are not testing for the `#f` case! I don't think we want this for beta release to end users, but we might start making something for our internal usage.

This is very nice. I didn't know about mutation testing! It would be a great addition to our testsuite.

Since you mentioned the blue/debugging/advice.scm module, I forgot we had this implemented, we should probably add advising to the list of features to review before the beta release #61.

This is very nice. I didn't know about mutation testing! It would be a great addition to our testsuite. Since you mentioned the `blue/debugging/advice.scm` module, I forgot we had this implemented, we should probably add advising to the list of features to review before the beta release #61.
old added this to the Backlog project 2025年09月11日 23:38:11 +02:00
Sign in to join this conversation.
No Branch/Tag specified
main
pipeline-operators
documentation
shadow-fields
instance-walker
blue-shell
promote-serializers-to-metacommands
pre-alpha
Labels
Clear labels
bug
Something is not working
contribution welcome
Contributions are very welcome, get started here
discussion
duplicate
This issue or pull request already exists
enhancement
New feature
good first issue
Interested in contributing? Get started here.
help wanted
Need some help
invalid
Something is wrong
optimization
question
More information is needed
upstream
Related to an upstream repository, already reported there
bug
Something is not working
contribution welcome
Contributions are very welcome, get started here
duplicate
This issue or pull request already exists
enhancement
New feature
good first issue
Interested in contributing? Get started here.
help wanted
Need some help
invalid
Something is wrong
question
More information is needed
upstream
Related to an upstream repository, already reported there
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lapislazuli/blue#65
Reference in a new issue
lapislazuli/blue
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?