Skip to content

Commit

Permalink
List own-mutants from in-tree config
Browse files Browse the repository at this point in the history
Concretely, this excludes console.rs, which is excluded in the config
  • Loading branch information
sourcefrog committed Jan 22, 2024
1 parent 752208b commit 38ac1a8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .cargo/mutants.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cargo-mutants configuration

error_values = ["::anyhow::anyhow!(\"mutated\")"]
error_values = ["::anyhow::anyhow!(\"mutated!\")"]
exclude_globs = ["src/console.rs"]
Original file line number Diff line number Diff line change
Expand Up @@ -25,128 +25,6 @@ src/config.rs: replace Config::read_file -> Result<Config> with Ok(Default::defa
src/config.rs: replace Config::read_file -> Result<Config> with Err(::anyhow::anyhow!("mutated!"))
src/config.rs: replace Config::read_tree_config -> Result<Config> with Ok(Default::default())
src/config.rs: replace Config::read_tree_config -> Result<Config> with Err(::anyhow::anyhow!("mutated!"))
src/console.rs: replace Console::walk_tree_start with ()
src/console.rs: replace Console::walk_tree_update with ()
src/console.rs: replace Console::walk_tree_done with ()
src/console.rs: replace Console::scenario_started -> Result<()> with Ok(())
src/console.rs: replace Console::scenario_started -> Result<()> with Err(::anyhow::anyhow!("mutated!"))
src/console.rs: replace Console::scenario_finished with ()
src/console.rs: replace += with -= in Console::scenario_finished
src/console.rs: replace += with *= in Console::scenario_finished
src/console.rs: replace += with -= in Console::scenario_finished
src/console.rs: replace += with *= in Console::scenario_finished
src/console.rs: replace += with -= in Console::scenario_finished
src/console.rs: replace += with *= in Console::scenario_finished
src/console.rs: replace += with -= in Console::scenario_finished
src/console.rs: replace += with *= in Console::scenario_finished
src/console.rs: replace += with -= in Console::scenario_finished
src/console.rs: replace += with *= in Console::scenario_finished
src/console.rs: replace += with -= in Console::scenario_finished
src/console.rs: replace += with *= in Console::scenario_finished
src/console.rs: replace += with -= in Console::scenario_finished
src/console.rs: replace += with *= in Console::scenario_finished
src/console.rs: replace || with && in Console::scenario_finished
src/console.rs: replace && with || in Console::scenario_finished
src/console.rs: replace && with || in Console::scenario_finished
src/console.rs: replace && with || in Console::scenario_finished
src/console.rs: replace || with && in Console::scenario_finished
src/console.rs: replace Console::start_copy with ()
src/console.rs: replace Console::finish_copy with ()
src/console.rs: replace Console::copy_progress with ()
src/console.rs: replace Console::discovered_mutants with ()
src/console.rs: replace Console::start_testing_mutants with ()
src/console.rs: replace Console::scenario_phase_started with ()
src/console.rs: replace Console::scenario_phase_finished with ()
src/console.rs: replace Console::lab_finished with ()
src/console.rs: replace Console::clear with ()
src/console.rs: replace Console::message with ()
src/console.rs: replace Console::tick with ()
src/console.rs: replace Console::make_terminal_writer -> TerminalWriter with Default::default()
src/console.rs: replace Console::make_debug_log_writer -> DebugLogWriter with Default::default()
src/console.rs: replace Console::set_debug_log with ()
src/console.rs: replace Console::setup_global_trace -> Result<()> with Ok(())
src/console.rs: replace Console::setup_global_trace -> Result<()> with Err(::anyhow::anyhow!("mutated!"))
src/console.rs: replace <impl MakeWriter for TerminalWriter>::make_writer -> Self::Writer with Default::default()
src/console.rs: replace <impl Write for TerminalWriter>::write -> std::io::Result<usize> with Ok(0)
src/console.rs: replace <impl Write for TerminalWriter>::write -> std::io::Result<usize> with Ok(1)
src/console.rs: replace <impl Write for TerminalWriter>::write -> std::io::Result<usize> with Err(::anyhow::anyhow!("mutated!"))
src/console.rs: replace <impl Write for TerminalWriter>::flush -> std::io::Result<()> with Err(::anyhow::anyhow!("mutated!"))
src/console.rs: replace <impl MakeWriter for DebugLogWriter>::make_writer -> Self::Writer with Default::default()
src/console.rs: replace <impl Write for DebugLogWriter>::write -> io::Result<usize> with Ok(0)
src/console.rs: replace <impl Write for DebugLogWriter>::write -> io::Result<usize> with Ok(1)
src/console.rs: replace <impl Write for DebugLogWriter>::write -> io::Result<usize> with Err(::anyhow::anyhow!("mutated!"))
src/console.rs: replace <impl Write for DebugLogWriter>::flush -> io::Result<()> with Ok(())
src/console.rs: replace <impl Write for DebugLogWriter>::flush -> io::Result<()> with Err(::anyhow::anyhow!("mutated!"))
src/console.rs: replace <impl Model for LabModel>::render -> String with String::new()
src/console.rs: replace <impl Model for LabModel>::render -> String with "xyzzy".into()
src/console.rs: replace += with -= in <impl Model for LabModel>::render
src/console.rs: replace += with *= in <impl Model for LabModel>::render
src/console.rs: replace > with == in <impl Model for LabModel>::render
src/console.rs: replace > with < in <impl Model for LabModel>::render
src/console.rs: replace > with == in <impl Model for LabModel>::render
src/console.rs: replace > with < in <impl Model for LabModel>::render
src/console.rs: replace > with == in <impl Model for LabModel>::render
src/console.rs: replace > with < in <impl Model for LabModel>::render
src/console.rs: replace > with == in <impl Model for LabModel>::render
src/console.rs: replace > with < in <impl Model for LabModel>::render
src/console.rs: replace > with == in <impl Model for LabModel>::render
src/console.rs: replace > with < in <impl Model for LabModel>::render
src/console.rs: replace - with + in <impl Model for LabModel>::render
src/console.rs: replace - with / in <impl Model for LabModel>::render
src/console.rs: replace / with % in <impl Model for LabModel>::render
src/console.rs: replace / with * in <impl Model for LabModel>::render
src/console.rs: replace * with + in <impl Model for LabModel>::render
src/console.rs: replace * with / in <impl Model for LabModel>::render
src/console.rs: replace > with == in <impl Model for LabModel>::render
src/console.rs: replace > with < in <impl Model for LabModel>::render
src/console.rs: replace * with + in <impl Model for LabModel>::render
src/console.rs: replace * with / in <impl Model for LabModel>::render
src/console.rs: replace / with % in <impl Model for LabModel>::render
src/console.rs: replace / with * in <impl Model for LabModel>::render
src/console.rs: replace + with - in <impl Model for LabModel>::render
src/console.rs: replace + with * in <impl Model for LabModel>::render
src/console.rs: replace LabModel::find_scenario_mut -> &mut ScenarioModel with Box::leak(Box::new(Default::default()))
src/console.rs: replace == with != in LabModel::find_scenario_mut
src/console.rs: replace LabModel::remove_scenario with ()
src/console.rs: replace != with == in LabModel::remove_scenario
src/console.rs: replace <impl Model for WalkModel>::render -> String with String::new()
src/console.rs: replace <impl Model for WalkModel>::render -> String with "xyzzy".into()
src/console.rs: replace == with != in <impl Model for WalkModel>::render
src/console.rs: replace ScenarioModel::phase_started with ()
src/console.rs: replace ScenarioModel::phase_finished with ()
src/console.rs: replace <impl Model for ScenarioModel>::render -> String with String::new()
src/console.rs: replace <impl Model for ScenarioModel>::render -> String with "xyzzy".into()
src/console.rs: replace CopyModel::bytes_copied with ()
src/console.rs: replace <impl Model for CopyModel>::render -> String with String::new()
src/console.rs: replace <impl Model for CopyModel>::render -> String with "xyzzy".into()
src/console.rs: replace nutmeg_options -> nutmeg::Options with Default::default()
src/console.rs: replace style_outcome -> StyledObject<&'static str> with StyledObject::new()
src/console.rs: replace style_outcome -> StyledObject<&'static str> with StyledObject::from_iter([""])
src/console.rs: replace style_outcome -> StyledObject<&'static str> with StyledObject::new("")
src/console.rs: replace style_outcome -> StyledObject<&'static str> with StyledObject::from("")
src/console.rs: replace style_outcome -> StyledObject<&'static str> with StyledObject::from_iter(["xyzzy"])
src/console.rs: replace style_outcome -> StyledObject<&'static str> with StyledObject::new("xyzzy")
src/console.rs: replace style_outcome -> StyledObject<&'static str> with StyledObject::from("xyzzy")
src/console.rs: replace style_secs -> String with String::new()
src/console.rs: replace style_secs -> String with "xyzzy".into()
src/console.rs: replace style_duration -> String with String::new()
src/console.rs: replace style_duration -> String with "xyzzy".into()
src/console.rs: replace format_mb -> String with String::new()
src/console.rs: replace format_mb -> String with "xyzzy".into()
src/console.rs: replace style_mb -> StyledObject<String> with StyledObject::new()
src/console.rs: replace style_mb -> StyledObject<String> with StyledObject::from_iter([String::new()])
src/console.rs: replace style_mb -> StyledObject<String> with StyledObject::new(String::new())
src/console.rs: replace style_mb -> StyledObject<String> with StyledObject::from(String::new())
src/console.rs: replace style_mb -> StyledObject<String> with StyledObject::from_iter(["xyzzy".into()])
src/console.rs: replace style_mb -> StyledObject<String> with StyledObject::new("xyzzy".into())
src/console.rs: replace style_mb -> StyledObject<String> with StyledObject::from("xyzzy".into())
src/console.rs: replace style_scenario -> Cow<'static, str> with Cow::Borrowed("")
src/console.rs: replace style_scenario -> Cow<'static, str> with Cow::Owned("".to_owned())
src/console.rs: replace style_scenario -> Cow<'static, str> with Cow::Borrowed("xyzzy")
src/console.rs: replace style_scenario -> Cow<'static, str> with Cow::Owned("xyzzy".to_owned())
src/console.rs: replace plural -> String with String::new()
src/console.rs: replace plural -> String with "xyzzy".into()
src/console.rs: replace == with != in plural
src/copy_tree.rs: replace copy_tree -> Result<TempDir> with Ok(Default::default())
src/copy_tree.rs: replace copy_tree -> Result<TempDir> with Err(::anyhow::anyhow!("mutated!"))
src/copy_tree.rs: replace += with -= in copy_tree
Expand Down
13 changes: 8 additions & 5 deletions src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,13 @@ fn attr_is_mutants_skip(attr: &Attribute) -> bool {

#[cfg(test)]
mod test {
use std::path::Path;

use indoc::indoc;
use itertools::Itertools;

use super::*;
use crate::config::Config;
use crate::package::Package;
use crate::source::SourceFile;

Expand Down Expand Up @@ -585,11 +588,11 @@ mod test {
/// To stop it being too noisy, we use a custom format with no line numbers.
#[test]
fn expected_mutants_for_own_source_tree() {
let options = Options {
error_values: vec!["::anyhow::anyhow!(\"mutated!\")".to_owned()],
show_line_col: false,
..Default::default()
};
let config = Config::read_file(Path::new("./.cargo/mutants.toml")).expect("Read config");
let args =
Args::try_parse_from(["mutants", "--list", "--line-col=false"]).expect("Parse args");
let mut options = Options::new(&args, &config).expect("Build options");
options.colors = false; // TODO: Use a command-line arg.
let mut list_output = String::new();
let console = Console::new();
let workspace = Workspace::open(
Expand Down

0 comments on commit 38ac1a8

Please sign in to comment.