diff options
Diffstat (limited to 'subplotlib/subplot-rust-support.rs')
-rw-r--r-- | subplotlib/subplot-rust-support.rs | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/subplotlib/subplot-rust-support.rs b/subplotlib/subplot-rust-support.rs index a63ef75..b502e7a 100644 --- a/subplotlib/subplot-rust-support.rs +++ b/subplotlib/subplot-rust-support.rs @@ -22,6 +22,7 @@ fn do_nothing(_context: &ScenarioContext) { #[step] #[context(SubplotContext)] #[context(Runcmd)] +#[allow(clippy::single_element_loop)] fn install_subplot(context: &ScenarioContext) { if let Some(bindir) = std::env::var_os("SUBPLOT_DIR") { println!("Found SUBPLOT_DIR environment variable, using that"); @@ -60,8 +61,6 @@ set -eu exec '{target_path}/{bin_name}' --resources '{src_dir}/share' "$@" "#, target_path = target_path.display(), - bin_name = bin_name, - src_dir = src_dir, ), )?; { @@ -91,21 +90,21 @@ fn uninstall_subplot(context: &mut SubplotContext) { #[step] #[context(Runcmd)] fn scenario_was_run(context: &ScenarioContext, name: &str) { - let text = format!("\nscenario: {}\n", name); + let text = format!("\nscenario: {name}\n"); runcmd::stdout_contains::call(context, &text)?; } #[step] #[context(Runcmd)] fn scenario_was_not_run(context: &ScenarioContext, name: &str) { - let text = format!("\nscenario: {}\n", name); + let text = format!("\nscenario: {name}\n"); runcmd::stdout_doesnt_contain::call(context, &text)?; } #[step] #[context(Runcmd)] fn step_was_run(context: &ScenarioContext, keyword: &str, name: &str) { - let text = format!("\n step: {} {}\n", keyword, name); + let text = format!("\n step: {keyword} {name}\n"); runcmd::stdout_contains::call(context, &text)?; } @@ -118,10 +117,7 @@ fn step_was_run_and_then( keyword2: &str, name2: &str, ) { - let text = format!( - "\n step: {} {}\n step: {} {}", - keyword1, name1, keyword2, name2 - ); + let text = format!("\n step: {keyword1} {name1}\n step: {keyword2} {name2}"); runcmd::stdout_contains::call(context, &text)?; } @@ -134,17 +130,14 @@ fn cleanup_was_run( keyword2: &str, name2: &str, ) { - let text = format!( - "\n cleanup: {} {}\n cleanup: {} {}\n", - keyword1, name1, keyword2, name2 - ); + let text = format!("\n cleanup: {keyword1} {name1}\n cleanup: {keyword2} {name2}\n"); runcmd::stdout_contains::call(context, &text)?; } #[step] #[context(Runcmd)] fn cleanup_was_not_run(context: &ScenarioContext, keyword: &str, name: &str) { - let text = format!("\n cleanup: {} {}\n", keyword, name); + let text = format!("\n cleanup: {keyword} {name}\n"); runcmd::stdout_doesnt_contain::call(context, &text)?; } @@ -161,7 +154,7 @@ fn end_of_file(context: &Datadir, filename: &str, nbytes: usize) -> Vec<u8> { fn file_ends_in_zero_newlines(context: &Datadir, filename: &str) { let b = end_of_file(context, filename, 1)?; if b[0] == b'\n' { - throw!(format!("File {} ends in unexpected newline", filename)); + throw!(format!("File {filename} ends in unexpected newline")); } } @@ -170,8 +163,7 @@ fn file_ends_in_one_newline(context: &Datadir, filename: &str) { let b = end_of_file(context, filename, 2)?; if !(b[0] != b'\n' && b[1] == b'\n') { throw!(format!( - "File {} does not end in exactly one newline", - filename + "File {filename} does not end in exactly one newline", )); } } @@ -181,18 +173,12 @@ fn file_ends_in_two_newlines(context: &Datadir, filename: &str) { let b = end_of_file(context, filename, 2)?; if b[0] != b'\n' || b[1] != b'\n' { throw!(format!( - "File {} does not end in exactly two newlines", - filename + "File {filename} does not end in exactly two newlines", )); } } #[step] -fn sleep_seconds(_context: &Datadir, delay: u64) { - std::thread::sleep(std::time::Duration::from_secs(delay)); -} - -#[step] #[context(Datadir)] #[context(Runcmd)] fn json_output_matches_file(context: &ScenarioContext, filename: &str) { @@ -208,12 +194,11 @@ fn json_output_matches_file(context: &ScenarioContext, filename: &str) { let output: serde_json::Value = serde_json::from_str(&output)?; let fcontent: serde_json::Value = serde_json::from_str(&fcontent)?; println!("########"); - println!("Output:\n{:#}", output); - println!("File:\n{:#}", fcontent); + println!("Output:\n{output:#}"); + println!("File:\n{fcontent:#}"); println!("########"); assert_eq!( output, fcontent, - "Command output does not match the content of {}", - filename + "Command output does not match the content of {filename}", ); } |