From 558b78dfaed6a390482a7bd54aed3f56f54203cd Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Fri, 15 Sep 2023 16:03:09 -0600 Subject: [PATCH] Test what mutants are generated for this tree --- src/console.rs | 27 +- ..._expected_mutants_for_own_source_tree.snap | 335 ++++++++++++++++++ src/visit.rs | 7 +- 3 files changed, 357 insertions(+), 12 deletions(-) create mode 100644 src/snapshots/cargo_mutants__visit__test__expected_mutants_for_own_source_tree.snap diff --git a/src/console.rs b/src/console.rs index 52fadcc8..df95ec3e 100644 --- a/src/console.rs +++ b/src/console.rs @@ -535,18 +535,23 @@ pub fn style_outcome(outcome: &ScenarioOutcome) -> StyledObject<&'static str> { pub(crate) fn style_mutant(mutant: &Mutant) -> String { // This is like `impl Display for Mutant`, but with colors. // The text content should be the same. - format!( - "{}: replace {}{}{} with {}", - mutant.describe_location(), - style(mutant.function_name()).bright().magenta(), - if mutant.return_type().is_empty() { - "" - } else { - " " - }, - style(mutant.return_type()).magenta(), - style(mutant.replacement_text()).yellow(), + let mut s = String::with_capacity(200); + write!( + &mut s, + "{}:{}", + mutant.source_file.tree_relative_slashes(), + mutant.span.start.line, ) + .unwrap(); + s.push_str(": replace "); + s.push_str(&style(mutant.function_name()).bright().magenta().to_string()); + if !mutant.return_type().is_empty() { + s.push(' '); + s.push_str(&style(mutant.return_type()).magenta().to_string()); + } + s.push_str(" with "); + s.push_str(&style(mutant.replacement_text()).yellow().to_string()); + s } fn style_elapsed_secs(since: Instant) -> String { diff --git a/src/snapshots/cargo_mutants__visit__test__expected_mutants_for_own_source_tree.snap b/src/snapshots/cargo_mutants__visit__test__expected_mutants_for_own_source_tree.snap new file mode 100644 index 00000000..9bf92810 --- /dev/null +++ b/src/snapshots/cargo_mutants__visit__test__expected_mutants_for_own_source_tree.snap @@ -0,0 +1,335 @@ +--- +source: src/visit.rs +expression: list_output +--- +src/main.rs: replace main -> Result<()> with Ok(()) +src/main.rs: replace main -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/build_dir.rs: replace BuildDir::path -> &Utf8Path with &Default::default() +src/build_dir.rs: replace BuildDir::copy -> Result with Ok(Default::default()) +src/build_dir.rs: replace BuildDir::copy -> Result with Err(::anyhow::anyhow!("mutated!")) +src/build_dir.rs: replace ::fmt -> fmt::Result with Ok(Default::default()) +src/build_dir.rs: replace ::fmt -> fmt::Result with Err(::anyhow::anyhow!("mutated!")) +src/build_dir.rs: replace copy_tree -> Result with Ok(Default::default()) +src/build_dir.rs: replace copy_tree -> Result with Err(::anyhow::anyhow!("mutated!")) +src/cargo.rs: replace ::name -> &str with "" +src/cargo.rs: replace ::name -> &str with "xyzzy" +src/cargo.rs: replace ::find_root -> Result with Ok(Default::default()) +src/cargo.rs: replace ::find_root -> Result with Err(::anyhow::anyhow!("mutated!")) +src/cargo.rs: replace ::top_source_files -> Result>> with Ok(vec![]) +src/cargo.rs: replace ::top_source_files -> Result>> with Ok(vec![Arc::new(Default::default())]) +src/cargo.rs: replace ::top_source_files -> Result>> with Err(::anyhow::anyhow!("mutated!")) +src/cargo.rs: replace ::compose_argv -> Result> with Ok(vec![]) +src/cargo.rs: replace ::compose_argv -> Result> with Ok(vec![String::new()]) +src/cargo.rs: replace ::compose_argv -> Result> with Ok(vec!["xyzzy".into()]) +src/cargo.rs: replace ::compose_argv -> Result> with Err(::anyhow::anyhow!("mutated!")) +src/cargo.rs: replace ::compose_env -> Result> with Ok(vec![]) +src/cargo.rs: replace ::compose_env -> Result> with Ok(vec![(String::new(), String::new())]) +src/cargo.rs: replace ::compose_env -> Result> with Ok(vec![(String::new(), "xyzzy".into())]) +src/cargo.rs: replace ::compose_env -> Result> with Ok(vec![("xyzzy".into(), String::new())]) +src/cargo.rs: replace ::compose_env -> Result> with Ok(vec![("xyzzy".into(), "xyzzy".into())]) +src/cargo.rs: replace ::compose_env -> Result> with Err(::anyhow::anyhow!("mutated!")) +src/cargo.rs: replace cargo_bin -> String with String::new() +src/cargo.rs: replace cargo_bin -> String with "xyzzy".into() +src/cargo.rs: replace cargo_argv -> Vec with vec![] +src/cargo.rs: replace cargo_argv -> Vec with vec![String::new()] +src/cargo.rs: replace cargo_argv -> Vec with vec!["xyzzy".into()] +src/cargo.rs: replace rustflags -> String with String::new() +src/cargo.rs: replace rustflags -> String with "xyzzy".into() +src/cargo.rs: replace direct_package_sources -> Result> with Ok(vec![]) +src/cargo.rs: replace direct_package_sources -> Result> with Ok(vec![Default::default()]) +src/cargo.rs: replace direct_package_sources -> Result> with Err(::anyhow::anyhow!("mutated!")) +src/cargo.rs: replace should_mutate_target -> bool with true +src/cargo.rs: replace should_mutate_target -> bool with false +src/config.rs: replace Config::read_file -> Result with Ok(Default::default()) +src/config.rs: replace Config::read_file -> Result with Err(::anyhow::anyhow!("mutated!")) +src/config.rs: replace Config::read_tree_config -> Result with Ok(Default::default()) +src/config.rs: replace Config::read_tree_config -> Result with Err(::anyhow::anyhow!("mutated!")) +src/console.rs: replace Console::scenario_started with () +src/console.rs: replace Console::scenario_finished with () +src/console.rs: replace Console::autoset_timeout 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::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 ::make_writer -> Self::Writer with Default::default() +src/console.rs: replace ::write -> std::io::Result with Ok(0) +src/console.rs: replace ::write -> std::io::Result with Ok(1) +src/console.rs: replace ::write -> std::io::Result with Err(::anyhow::anyhow!("mutated!")) +src/console.rs: replace ::flush -> std::io::Result<()> with Ok(()) +src/console.rs: replace ::flush -> std::io::Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/console.rs: replace ::make_writer -> Self::Writer with Default::default() +src/console.rs: replace ::write -> io::Result with Ok(0) +src/console.rs: replace ::write -> io::Result with Ok(1) +src/console.rs: replace ::write -> io::Result with Err(::anyhow::anyhow!("mutated!")) +src/console.rs: replace ::flush -> io::Result<()> with Ok(()) +src/console.rs: replace ::flush -> io::Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/console.rs: replace ::render -> String with String::new() +src/console.rs: replace ::render -> String with "xyzzy".into() +src/console.rs: replace LabModel::find_scenario_mut -> &mut ScenarioModel with Box::leak(Box::new(Default::default())) +src/console.rs: replace LabModel::remove_scenario with () +src/console.rs: replace ScenarioModel::phase_started with () +src/console.rs: replace ScenarioModel::phase_finished with () +src/console.rs: replace ::render -> String with String::new() +src/console.rs: replace ::render -> String with "xyzzy".into() +src/console.rs: replace CopyModel::bytes_copied with () +src/console.rs: replace ::render -> String with String::new() +src/console.rs: replace ::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_mutant -> String with String::new() +src/console.rs: replace style_mutant -> String with "xyzzy".into() +src/console.rs: replace style_elapsed_secs -> String with String::new() +src/console.rs: replace style_elapsed_secs -> String with "xyzzy".into() +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_minutes_seconds -> String with String::new() +src/console.rs: replace style_minutes_seconds -> String with "xyzzy".into() +src/console.rs: replace duration_minutes_seconds -> String with String::new() +src/console.rs: replace duration_minutes_seconds -> 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 with StyledObject::new() +src/console.rs: replace style_mb -> StyledObject with StyledObject::from_iter([String::new()]) +src/console.rs: replace style_mb -> StyledObject with StyledObject::new(String::new()) +src/console.rs: replace style_mb -> StyledObject with StyledObject::from(String::new()) +src/console.rs: replace style_mb -> StyledObject with StyledObject::from_iter(["xyzzy".into()]) +src/console.rs: replace style_mb -> StyledObject with StyledObject::new("xyzzy".into()) +src/console.rs: replace style_mb -> StyledObject 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/fnvalue.rs: replace return_type_replacements -> impl Iterator with Default::default() +src/fnvalue.rs: replace type_replacements -> impl Iterator with Default::default() +src/fnvalue.rs: replace path_ends_with -> bool with true +src/fnvalue.rs: replace path_ends_with -> bool with false +src/fnvalue.rs: replace known_container -> Option<(&Ident, &Type)> with None +src/fnvalue.rs: replace known_container -> Option<(&Ident, &Type)> with Some((&Default::default(), &Default::default())) +src/fnvalue.rs: replace known_collection -> Option<(&Ident, &Type)> with None +src/fnvalue.rs: replace known_collection -> Option<(&Ident, &Type)> with Some((&Default::default(), &Default::default())) +src/fnvalue.rs: replace maybe_collection_or_container -> Option<(&Ident, &Type)> with None +src/fnvalue.rs: replace maybe_collection_or_container -> Option<(&Ident, &Type)> with Some((&Default::default(), &Default::default())) +src/fnvalue.rs: replace path_is_float -> bool with true +src/fnvalue.rs: replace path_is_float -> bool with false +src/fnvalue.rs: replace path_is_unsigned -> bool with true +src/fnvalue.rs: replace path_is_unsigned -> bool with false +src/fnvalue.rs: replace path_is_signed -> bool with true +src/fnvalue.rs: replace path_is_signed -> bool with false +src/fnvalue.rs: replace path_is_nonzero_signed -> bool with true +src/fnvalue.rs: replace path_is_nonzero_signed -> bool with false +src/fnvalue.rs: replace path_is_nonzero_unsigned -> bool with true +src/fnvalue.rs: replace path_is_nonzero_unsigned -> bool with false +src/fnvalue.rs: replace match_first_type_arg -> Option<&'p Type> with None +src/fnvalue.rs: replace match_first_type_arg -> Option<&'p Type> with Some(&Default::default()) +src/interrupt.rs: replace install_handler with () +src/lab.rs: replace test_unmutated_then_all_mutants -> Result with Ok(Default::default()) +src/lab.rs: replace test_unmutated_then_all_mutants -> Result with Err(::anyhow::anyhow!("mutated!")) +src/lab.rs: replace test_scenario -> Result with Ok(Default::default()) +src/lab.rs: replace test_scenario -> Result with Err(::anyhow::anyhow!("mutated!")) +src/list.rs: replace >::write_str -> Result<(), fmt::Error> with Ok(()) +src/list.rs: replace >::write_str -> Result<(), fmt::Error> with Err(::anyhow::anyhow!("mutated!")) +src/list.rs: replace list_mutants -> Result<()> with Ok(()) +src/list.rs: replace list_mutants -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/list.rs: replace list_files -> Result<()> with Ok(()) +src/list.rs: replace list_files -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/log_file.rs: replace LogFile::create_in -> Result with Ok(Default::default()) +src/log_file.rs: replace LogFile::create_in -> Result with Err(::anyhow::anyhow!("mutated!")) +src/log_file.rs: replace LogFile::open_append -> Result with Ok(Default::default()) +src/log_file.rs: replace LogFile::open_append -> Result with Err(::anyhow::anyhow!("mutated!")) +src/log_file.rs: replace LogFile::message with () +src/log_file.rs: replace LogFile::path -> &Utf8Path with &Default::default() +src/log_file.rs: replace last_line -> Result with Ok(String::new()) +src/log_file.rs: replace last_line -> Result with Ok("xyzzy".into()) +src/log_file.rs: replace last_line -> Result with Err(::anyhow::anyhow!("mutated!")) +src/log_file.rs: replace clean_filename -> String with String::new() +src/log_file.rs: replace clean_filename -> String with "xyzzy".into() +src/manifest.rs: replace fix_manifest -> Result<()> with Ok(()) +src/manifest.rs: replace fix_manifest -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/manifest.rs: replace fix_manifest_toml -> Result> with Ok(None) +src/manifest.rs: replace fix_manifest_toml -> Result> with Ok(Some(Default::default())) +src/manifest.rs: replace fix_manifest_toml -> Result> with Err(::anyhow::anyhow!("mutated!")) +src/manifest.rs: replace fix_dependency_table with () +src/manifest.rs: replace fix_cargo_config -> Result<()> with Ok(()) +src/manifest.rs: replace fix_cargo_config -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/manifest.rs: replace fix_cargo_config_toml -> Result> with Ok(None) +src/manifest.rs: replace fix_cargo_config_toml -> Result> with Ok(Some(String::new())) +src/manifest.rs: replace fix_cargo_config_toml -> Result> with Ok(Some("xyzzy".into())) +src/manifest.rs: replace fix_cargo_config_toml -> Result> with Err(::anyhow::anyhow!("mutated!")) +src/manifest.rs: replace fix_path -> Option with None +src/manifest.rs: replace fix_path -> Option with Some(String::new()) +src/manifest.rs: replace fix_path -> Option with Some("xyzzy".into()) +src/mutate.rs: replace Mutant::mutated_code -> String with String::new() +src/mutate.rs: replace Mutant::mutated_code -> String with "xyzzy".into() +src/mutate.rs: replace Mutant::original_code -> &str with "" +src/mutate.rs: replace Mutant::original_code -> &str with "xyzzy" +src/mutate.rs: replace Mutant::return_type -> &str with "" +src/mutate.rs: replace Mutant::return_type -> &str with "xyzzy" +src/mutate.rs: replace Mutant::describe_location -> String with String::new() +src/mutate.rs: replace Mutant::describe_location -> String with "xyzzy".into() +src/mutate.rs: replace Mutant::describe_change -> String with String::new() +src/mutate.rs: replace Mutant::describe_change -> String with "xyzzy".into() +src/mutate.rs: replace Mutant::replacement_text -> &str with "" +src/mutate.rs: replace Mutant::replacement_text -> &str with "xyzzy" +src/mutate.rs: replace Mutant::function_name -> &str with "" +src/mutate.rs: replace Mutant::function_name -> &str with "xyzzy" +src/mutate.rs: replace Mutant::package_name -> &str with "" +src/mutate.rs: replace Mutant::package_name -> &str with "xyzzy" +src/mutate.rs: replace Mutant::package -> &Package with &Default::default() +src/mutate.rs: replace Mutant::diff -> String with String::new() +src/mutate.rs: replace Mutant::diff -> String with "xyzzy".into() +src/mutate.rs: replace Mutant::apply -> Result<()> with Ok(()) +src/mutate.rs: replace Mutant::apply -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/mutate.rs: replace Mutant::unapply -> Result<()> with Ok(()) +src/mutate.rs: replace Mutant::unapply -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/mutate.rs: replace Mutant::write_in_dir -> Result<()> with Ok(()) +src/mutate.rs: replace Mutant::write_in_dir -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/mutate.rs: replace Mutant::log_file_name_base -> String with String::new() +src/mutate.rs: replace Mutant::log_file_name_base -> String with "xyzzy".into() +src/mutate.rs: replace ::fmt -> fmt::Result with Ok(Default::default()) +src/mutate.rs: replace ::fmt -> fmt::Result with Err(::anyhow::anyhow!("mutated!")) +src/mutate.rs: replace ::fmt -> fmt::Result with Ok(Default::default()) +src/mutate.rs: replace ::fmt -> fmt::Result with Err(::anyhow::anyhow!("mutated!")) +src/mutate.rs: replace ::serialize -> Result with Ok(Default::default()) +src/mutate.rs: replace ::serialize -> Result with Err(::anyhow::anyhow!("mutated!")) +src/options.rs: replace join_slices -> Vec with vec![] +src/options.rs: replace join_slices -> Vec with vec![String::new()] +src/options.rs: replace join_slices -> Vec with vec!["xyzzy".into()] +src/options.rs: replace build_glob_set -> Result> with Ok(None) +src/options.rs: replace build_glob_set -> Result> with Ok(Some(Default::default())) +src/options.rs: replace build_glob_set -> Result> with Err(::anyhow::anyhow!("mutated!")) +src/outcome.rs: replace Phase::name -> &'static str with "" +src/outcome.rs: replace Phase::name -> &'static str with "xyzzy" +src/outcome.rs: replace ::fmt -> fmt::Result with Ok(Default::default()) +src/outcome.rs: replace ::fmt -> fmt::Result with Err(::anyhow::anyhow!("mutated!")) +src/outcome.rs: replace LabOutcome::add with () +src/outcome.rs: replace LabOutcome::exit_code -> i32 with 0 +src/outcome.rs: replace LabOutcome::exit_code -> i32 with 1 +src/outcome.rs: replace LabOutcome::exit_code -> i32 with -1 +src/outcome.rs: replace LabOutcome::summary_string -> String with String::new() +src/outcome.rs: replace LabOutcome::summary_string -> String with "xyzzy".into() +src/outcome.rs: replace ::serialize -> Result with Ok(Default::default()) +src/outcome.rs: replace ::serialize -> Result with Err(::anyhow::anyhow!("mutated!")) +src/outcome.rs: replace ScenarioOutcome::add_phase_result with () +src/outcome.rs: replace ScenarioOutcome::get_log_content -> Result with Ok(String::new()) +src/outcome.rs: replace ScenarioOutcome::get_log_content -> Result with Ok("xyzzy".into()) +src/outcome.rs: replace ScenarioOutcome::get_log_content -> Result with Err(::anyhow::anyhow!("mutated!")) +src/outcome.rs: replace ScenarioOutcome::last_phase -> Phase with Default::default() +src/outcome.rs: replace ScenarioOutcome::last_phase_result -> ProcessStatus with Default::default() +src/outcome.rs: replace ScenarioOutcome::phase_results -> &[PhaseResult] with Vec::leak(Vec::new()) +src/outcome.rs: replace ScenarioOutcome::phase_results -> &[PhaseResult] with Vec::leak(vec![Default::default()]) +src/outcome.rs: replace ScenarioOutcome::should_show_logs -> bool with true +src/outcome.rs: replace ScenarioOutcome::should_show_logs -> bool with false +src/outcome.rs: replace ScenarioOutcome::success -> bool with true +src/outcome.rs: replace ScenarioOutcome::success -> bool with false +src/outcome.rs: replace ScenarioOutcome::has_timeout -> bool with true +src/outcome.rs: replace ScenarioOutcome::has_timeout -> bool with false +src/outcome.rs: replace ScenarioOutcome::check_or_build_failed -> bool with true +src/outcome.rs: replace ScenarioOutcome::check_or_build_failed -> bool with false +src/outcome.rs: replace ScenarioOutcome::mutant_caught -> bool with true +src/outcome.rs: replace ScenarioOutcome::mutant_caught -> bool with false +src/outcome.rs: replace ScenarioOutcome::mutant_missed -> bool with true +src/outcome.rs: replace ScenarioOutcome::mutant_missed -> bool with false +src/outcome.rs: replace ScenarioOutcome::summary -> SummaryOutcome with Default::default() +src/outcome.rs: replace ::serialize -> Result with Ok(Default::default()) +src/outcome.rs: replace ::serialize -> Result with Err(::anyhow::anyhow!("mutated!")) +src/output.rs: replace LockFile::acquire_lock -> Result with Ok(Default::default()) +src/output.rs: replace LockFile::acquire_lock -> Result with Err(::anyhow::anyhow!("mutated!")) +src/output.rs: replace OutputDir::create_log -> Result with Ok(Default::default()) +src/output.rs: replace OutputDir::create_log -> Result with Err(::anyhow::anyhow!("mutated!")) +src/output.rs: replace OutputDir::path -> &Utf8Path with &Default::default() +src/output.rs: replace OutputDir::write_lab_outcome -> Result<()> with Ok(()) +src/output.rs: replace OutputDir::write_lab_outcome -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/output.rs: replace OutputDir::add_scenario_outcome -> Result<()> with Ok(()) +src/output.rs: replace OutputDir::add_scenario_outcome -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/output.rs: replace OutputDir::open_debug_log -> Result with Ok(Default::default()) +src/output.rs: replace OutputDir::open_debug_log -> Result with Err(::anyhow::anyhow!("mutated!")) +src/output.rs: replace OutputDir::write_mutants_list -> Result<()> with Ok(()) +src/output.rs: replace OutputDir::write_mutants_list -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/output.rs: replace OutputDir::take_lab_outcome -> LabOutcome with Default::default() +src/path.rs: replace ascent -> isize with 0 +src/path.rs: replace ascent -> isize with 1 +src/path.rs: replace ascent -> isize with -1 +src/path.rs: replace ::to_slash_path -> String with String::new() +src/path.rs: replace ::to_slash_path -> String with "xyzzy".into() +src/pretty.rs: replace ::to_pretty_string -> String with String::new() +src/pretty.rs: replace ::to_pretty_string -> String with "xyzzy".into() +src/process.rs: replace Process::run -> Result with Ok(Default::default()) +src/process.rs: replace Process::run -> Result with Err(::anyhow::anyhow!("mutated!")) +src/process.rs: replace Process::start -> Result with Ok(Default::default()) +src/process.rs: replace Process::start -> Result with Err(::anyhow::anyhow!("mutated!")) +src/process.rs: replace Process::terminate -> Result<()> with Ok(()) +src/process.rs: replace Process::terminate -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/process.rs: replace terminate_child_impl -> Result<()> with Ok(()) +src/process.rs: replace terminate_child_impl -> Result<()> with Err(::anyhow::anyhow!("mutated!")) +src/process.rs: replace ProcessStatus::success -> bool with true +src/process.rs: replace ProcessStatus::success -> bool with false +src/process.rs: replace ProcessStatus::timeout -> bool with true +src/process.rs: replace ProcessStatus::timeout -> bool with false +src/process.rs: replace setpgid_on_unix -> PopenConfig with Default::default() +src/process.rs: replace get_command_output -> Result with Ok(String::new()) +src/process.rs: replace get_command_output -> Result with Ok("xyzzy".into()) +src/process.rs: replace get_command_output -> Result with Err(::anyhow::anyhow!("mutated!")) +src/scenario.rs: replace ::fmt -> fmt::Result with Ok(Default::default()) +src/scenario.rs: replace ::fmt -> fmt::Result with Err(::anyhow::anyhow!("mutated!")) +src/scenario.rs: replace Scenario::is_mutant -> bool with true +src/scenario.rs: replace Scenario::is_mutant -> bool with false +src/scenario.rs: replace Scenario::log_file_name_base -> String with String::new() +src/scenario.rs: replace Scenario::log_file_name_base -> String with "xyzzy".into() +src/scenario.rs: replace Scenario::package -> Option<&Package> with None +src/scenario.rs: replace Scenario::package -> Option<&Package> with Some(&Default::default()) +src/source.rs: replace SourceFile::tree_relative_slashes -> String with String::new() +src/source.rs: replace SourceFile::tree_relative_slashes -> String with "xyzzy".into() +src/textedit.rs: replace ::from -> Self with Default::default() +src/textedit.rs: replace ::from -> Self with Default::default() +src/textedit.rs: replace ::from -> Self with Default::default() +src/textedit.rs: replace replace_region -> String with String::new() +src/textedit.rs: replace replace_region -> String with "xyzzy".into() +src/visit.rs: replace walk_tree -> Result with Ok(Default::default()) +src/visit.rs: replace walk_tree -> Result with Err(::anyhow::anyhow!("mutated!")) +src/visit.rs: replace walk_file -> Result<(Vec, Vec)> with Ok((vec![], vec![])) +src/visit.rs: replace walk_file -> Result<(Vec, Vec)> with Ok((vec![], vec![String::new()])) +src/visit.rs: replace walk_file -> Result<(Vec, Vec)> with Ok((vec![], vec!["xyzzy".into()])) +src/visit.rs: replace walk_file -> Result<(Vec, Vec)> with Ok((vec![Default::default()], vec![])) +src/visit.rs: replace walk_file -> Result<(Vec, Vec)> with Ok((vec![Default::default()], vec![String::new()])) +src/visit.rs: replace walk_file -> Result<(Vec, Vec)> with Ok((vec![Default::default()], vec!["xyzzy".into()])) +src/visit.rs: replace walk_file -> Result<(Vec, Vec)> with Err(::anyhow::anyhow!("mutated!")) +src/visit.rs: replace DiscoveryVisitor<'o>::collect_fn_mutants with () +src/visit.rs: replace DiscoveryVisitor<'o>::in_namespace -> T with Default::default() +src/visit.rs: replace >::visit_item_fn with () +src/visit.rs: replace >::visit_impl_item_fn with () +src/visit.rs: replace >::visit_item_impl with () +src/visit.rs: replace >::visit_item_mod with () +src/visit.rs: replace find_mod_source -> Result> with Ok(None) +src/visit.rs: replace find_mod_source -> Result> with Ok(Some(Default::default())) +src/visit.rs: replace find_mod_source -> Result> with Err(::anyhow::anyhow!("mutated!")) +src/visit.rs: replace fn_sig_excluded -> bool with true +src/visit.rs: replace fn_sig_excluded -> bool with false +src/visit.rs: replace attrs_excluded -> bool with true +src/visit.rs: replace attrs_excluded -> bool with false +src/visit.rs: replace block_is_empty -> bool with true +src/visit.rs: replace block_is_empty -> bool with false +src/visit.rs: replace attr_is_cfg_test -> bool with true +src/visit.rs: replace attr_is_cfg_test -> bool with false +src/visit.rs: replace attr_is_test -> bool with true +src/visit.rs: replace attr_is_test -> bool with false +src/visit.rs: replace path_is -> bool with true +src/visit.rs: replace path_is -> bool with false +src/visit.rs: replace attr_is_mutants_skip -> bool with true +src/visit.rs: replace attr_is_mutants_skip -> bool with false + diff --git a/src/visit.rs b/src/visit.rs index bcfafc4c..1e995adf 100644 --- a/src/visit.rs +++ b/src/visit.rs @@ -382,6 +382,8 @@ fn attr_is_mutants_skip(attr: &Attribute) -> bool { #[cfg(test)] mod test { + use regex::Regex; + use crate::cargo::CargoTool; use super::*; @@ -410,6 +412,9 @@ mod test { ) .expect("Discover mutants in own source tree"); - println!("{list_output}"); + // Strip line numbers so this is not too brittle. + let line_re = Regex::new(r"(?m)^([^:]+:)\d+:( .*)$").unwrap(); + let list_output = line_re.replace_all(&list_output, "$1$2"); + insta::assert_snapshot!(list_output); } }