{"id":21711917,"url":"https://github.com/zalanlevai/mutest-rs","last_synced_at":"2025-04-12T17:43:54.571Z","repository":{"id":41879149,"uuid":"419872515","full_name":"zalanlevai/mutest-rs","owner":"zalanlevai","description":"Mutation testing tools for Rust","archived":false,"fork":false,"pushed_at":"2025-03-07T15:48:18.000Z","size":2825,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T12:04:02.313Z","etag":null,"topics":["mutation-analysis","mutation-testing","rust-lang"],"latest_commit_sha":null,"homepage":"https://mutest.rs","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zalanlevai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-21T20:48:29.000Z","updated_at":"2025-03-07T15:48:21.000Z","dependencies_parsed_at":"2023-10-11T20:18:48.524Z","dependency_job_id":"6afe9dd7-5312-4a34-bc30-64605a742451","html_url":"https://github.com/zalanlevai/mutest-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalanlevai%2Fmutest-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalanlevai%2Fmutest-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalanlevai%2Fmutest-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalanlevai%2Fmutest-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zalanlevai","download_url":"https://codeload.github.com/zalanlevai/mutest-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248609048,"owners_count":21132836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mutation-analysis","mutation-testing","rust-lang"],"created_at":"2024-11-25T23:31:44.529Z","updated_at":"2025-04-12T17:43:54.539Z","avatar_url":"https://github.com/zalanlevai.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mutest-rs \u0026mdash; Mutation testing tools for Rust\n\n[![Docs](https://img.shields.io/badge/mutest.rs-black?logo=mdbook)](https://mutest.rs)\n[![DOI 10.1109/ICST57152.2023.00014](https://img.shields.io/badge/10.1109%2FICST57152.2023.00014-black?logo=DOI)](https://doi.org/10.1109/ICST57152.2023.00014)\n\nGenerate and analyze runtime-swappable code mutants of Rust programs using a dynamic set of abstract mutation operators. For more information, see [the mutest-rs book](https://mutest.rs).\n\n![Output of mutest](docs/res/output.png)\n\n\u003e [!NOTE]\n\u003e mutest-rs is primarily a research tool, but is an extremely capable mutation testing tool for all use cases. It was originally developed for my ongoing PhD work.\n\n## Mutation Operators\n\nCurrently, the following list of mutation operators are implemented:\n\n| Mutation Operator           | Short Description                                                      |\n| --------------------------- | ---------------------------------------------------------------------- |\n| `arg_default_shadow`        | Ignore argument by shadowing it with `Default::default()`.             |\n| `bit_op_or_and_swap`        | Swap bitwise OR for bitwise AND and vice versa.                        |\n| `bit_op_or_xor_swap`        | Swap bitwise OR for bitwise XOR and vice versa.                        |\n| `bit_op_shift_dir_swap`     | Swap the direction of bitwise shift operator.                          |\n| `bit_op_xor_and_swap`       | Swap bitwise XOR for bitwise AND and vice versa.                       |\n| `bool_expr_negate`          | Negate boolean expression.                                             |\n| `call_delete`               | Delete call and replace it with `Default::default()`.                  |\n| `call_value_default_shadow` | Ignore return value of call by shadowing it with `Default::default()`. |\n| `continue_break_swap`       | Swap continue for break and vice versa.                                |\n| `eq_op_invert`              | Invert equality check.                                                 |\n| `logical_op_and_or_swap`    | Swap logical *and* for logical *or* and vice versa.                    |\n| `math_op_add_mul_swap`      | Swap addition for multiplication and vice versa.                       |\n| `math_op_add_sub_swap`      | Swap addition for subtraction and vice versa.                          |\n| `math_op_div_rem_swap`      | Swap division for modulus and vice versa.                              |\n| `math_op_mul_div_swap`      | Swap multiplication for division and vice versa.                       |\n| `range_limit_swap`          | Swap limit (inclusivity) of range expression.                          |\n| `relational_op_eq_swap`     | Include or remove the boundary (equality) of relational operator.      |\n| `relational_op_invert`      | Invert relation operator.                                              |\n\nFor more information, and examples, see [docs/operators.md](docs/operators.md).\n\n## Build\n\n\u003e `mutest` relies on the nightly compiler toolchain. `rustup` is configured to automatically install and use the right nightly version.\n\nBuild the `mutest-runtime` crate in release mode.\n\n```sh\ncargo build --release -p mutest-runtime\n```\n\nInstall `mutest-driver` and the Cargo subcommand `cargo-mutest` locally.\n\n```sh\ncargo install --force --path mutest-driver\ncargo install --force --path cargo-mutest\n```\n\n\u003e The release build of `mutest-driver` looks for a release build of `mutest-runtime`. A local install with `cargo install` will produce a release build.\n\n## Usage\n\n\u003e [!IMPORTANT]\n\u003e Currently, the invocation of the tool requires manually specifying the following values:\n\u003e * `MUTEST_SEARCH_PATH`: environment variable pointing to the local build artifacts.\n\u003e\n\u003e In addition, the Cargo test target may have to be specified explicitly with the `--lib` or `--bin \u003cBIN\u003e` options. For more targeting options, see `--help`.\n\u003e\n\u003e Thus, a typical invocation, with the code checked out and built in `~/Developer/mutest-rs` and a library target will look as follows:\n\u003e\n\u003e ```sh\n\u003e export MUTEST_SEARCH_PATH=~/Developer/mutest-rs/target/release\n\u003e cargo mutest --lib run\n\u003e ```\n\nRun the `cargo mutest` subcommand against a standard Cargo package directory or workspace containing your crate.\n\n```sh\ncargo mutest -p \u003cPACKAGE\u003e run\n```\n\nSee `--help` for more options and subcommands.\n\n### Using `cfg(mutest)`\n\nWhen running `cargo mutest`, the `mutest` cfg is set. This can be used to detect if code is running under mutest-rs, and enable conditional compilation based on it.\n\nStarting with Rust 1.80, cfgs are checked against a known set of config names and values. If your Cargo package is checked with a regular Cargo command, it will warn you about the \"unexpected\" `mutest` cfg. To [let rustc know that this custom cfg is expected](https://blog.rust-lang.org/2024/05/06/check-cfg.html#expecting-custom-cfgs), ensure that `cfg(mutest)` is present in the `[lints.rust.unexpected_cfgs.check-cfg]` array in the package's `Cargo.toml`, like so:\n\n```toml\n[lints.rust]\nunexpected_cfgs = { level = \"warn\", check-cfg = [\"cfg(mutest)\"] }\n```\n\n### Annotating code with tool attributes\n\nmutest-rs provides [tool attributes](https://doc.rust-lang.org/reference/attributes.html#tool-attributes) that can be used to optionally annotate your code for use with the tool. Note, that these attributes are only available when running `cargo mutest`, so they need to be wrapped in `#[cfg_attr(mutest, \u003cMUTEST_ATTRIBUTE\u003e)]` for regular Cargo commands to run.\n\n#### `#[mutest::skip]` (use `#[cfg_attr(mutest, mutest::skip)]`)\n\nTells mutest-rs to skip the function when applying mutation operators. Useful for marking helper functions for tests (test cases themselves are automatically skipped).\n\nThis attribute can only be applied to function declarations:\n```rs\n#[cfg_attr(mutest, mutest::skip)]\nfn perform_tests() {\n```\n\n#### `#[mutest::ignore]` (use `#[cfg_attr(mutest, mutest::ignore)]`)\n\nTells mutest-rs to ignore the statement or expression, including any subexpressions, or function parameter, when applying mutation operators. Useful if mutest-rs is trying to apply mutations to a critical piece of code that might be causing problems.\n\nThis attribute can be applied to\n* statements (note that expression statements might have to be wrapped in `{}`, [see this linked Rust issue](https://github.com/rust-lang/rust/issues/59144)):\n  ```rs\n  #[cfg_attr(mutest, mutest::ignore)]\n  let buff_len = mem::size_of::\u003cu16\u003e() * 1024;\n  ```\n* expressions ([wherever the compiler supports attrbiutes on expressions](https://doc.rust-lang.org/reference/expressions.html#expression-attributes)):\n  ```rs\n      #[cfg_attr(mutest, mutest::ignore)]\n      Some(body)\n  }\n   ```\n* and function parameters:\n  ```rs\n  fn foo(\u0026self, #[cfg_attr(mutest, mutest::ignore)] experimental: bool) {\n  ```\n\n## License\n\nThe mutest-rs project is dual-licensed under Apache 2.0 and MIT terms.\n\nSee [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and [COPYRIGHT](COPYRIGHT) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalanlevai%2Fmutest-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzalanlevai%2Fmutest-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalanlevai%2Fmutest-rs/lists"}