You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`cargo mutants` takes various options to control how it runs. These options are shown in `cargo mutants --help` and are described in detail in this section.
3
+
`cargo mutants` takes various options to control how it runs.
4
+
5
+
These options, can, in general, be passed on the command line, set in a `.cargo/mutants.toml`
6
+
file in the source tree, or passed in `CARGO_MUTANTS_` environment variables. Not every
7
+
method of setting an option is available for every option, however, as some would not
8
+
make sense or be useful.
9
+
10
+
For options that take a list of values, values from the configuration file are appended
11
+
to values from the command line.
12
+
13
+
For options that take a single value, the value from the command line takes precedence.
14
+
15
+
`--no-config` can be used to disable reading the configuration file.
16
+
17
+
## Execution order
4
18
5
19
By default, mutants are run in a randomized order, so as to surface results from
6
20
different parts of the codebase earlier. This can be disabled with
7
-
`--no-shuffle`, in which case mutants will run in the same order shown by
8
-
`--list`: in order by file name and within each file in the order they appear in
21
+
`--no-shuffle`, in which case mutants will run in order by file name and within each file in the order they appear in
9
22
the source.
10
23
11
24
## Source directory location
12
25
13
-
`-d`, `--dir`: Test the Rust tree in the given directory, rather than the default directory.
26
+
`-d`, `--dir`: Test the Rust tree in the given directory, rather than the source tree
27
+
enclosing the working directory where cargo-mutants is launched.
14
28
15
29
## Console output
16
30
@@ -20,10 +34,6 @@ the source.
20
34
21
35
`--no-times`: Don't print elapsed times.
22
36
23
-
## Environment variables
24
-
25
-
A few options that may be useful to set globally can be configured through environment
26
-
variables:
27
-
28
-
*`CARGO_MUTANTS_JOBS`
29
-
*`CARGO_MUTANTS_TRACE_LEVEL`
37
+
`-L`, `--level`, and `$CARGO_MUTANTS_TRACE_LEVEL`: set the verbosity of trace
38
+
output to stdout. The default is `info`, and it can be increased to `debug` or
cargo-mutants can be configured to generate mutants that return an error value from functions that return a Result.
4
+
5
+
This will flag cases where no test fails if the function returns an error: that might happen if there are _only_ tests for the error cases and not for the Ok case.
6
+
7
+
Since crates can choose to use any type for their error values,
8
+
cargo-mutants must be told how to construct an appropriate error.
9
+
10
+
The `--error` command line option and the `error_value` configuration option specify an error value to use.
11
+
12
+
These options can be repeated or combined, which might be useful
13
+
if there are multiple error types in the crate. On any one mutation site, probably only one of the error values will be viable, and cargo-mutants will discover that and use it.
14
+
15
+
The error value can be any Rust expression that evaluates to a value of the error type. It should not include the `Err` wrapper, because cargo-mutants will add that.
16
+
17
+
For example, if your crate uses `anyhow::Error` as its error type, you might use `--error '::anyhow::anyhow!("error")'`.
18
+
19
+
If you have your own error type, you might use `--error 'crate::MyError::Generic'`.
20
+
21
+
Since the correct error type is a property of the source tree, the configuration should typically go into `.cargo/mutants.toml` rather than being specified on the command line:
22
+
23
+
```toml
24
+
error_values = ["::anyhow::anyhow!(\"mutated\")"]
25
+
```
26
+
27
+
To see only the mutants generated by this configuration, you
0 commit comments