Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: pre-commit/[email protected]
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ We ask that commits are atomic, meaning they are complete and have a single resp
PRs should tell a cohesive story, with test and refactor commits that keep the
fix or feature commits simple and clear.

Specifically, we would encouage
Specifically, we would encourage
- File renames be isolated into their own commit
- Add tests in a commit before their feature or fix, showing the current behavior.
The diff for the feature/fix commit will then show how the behavior changed,
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ string_lit_as_bytes = "warn"
string_to_string = "warn"
todo = "warn"
trait_duplication_in_bounds = "warn"
uninlined_format_args = "warn"
verbose_file_reads = "warn"
wildcard_imports = "warn"
zero_sized_map_values = "warn"
Expand Down
6 changes: 3 additions & 3 deletions examples/example_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::process;

fn run() -> Result<(), Box<dyn Error>> {
if let Ok(text) = env::var("stdout") {
println!("{}", text);
println!("{text}");
}
if let Ok(text) = env::var("stderr") {
eprintln!("{}", text);
eprintln!("{text}");
}

let code = env::var("exit")
Expand All @@ -27,7 +27,7 @@ fn main() {
let code = match run() {
Ok(_) => 0,
Err(ref e) => {
write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail");
write!(&mut io::stderr(), "{e}").expect("writing to stderr won't fail");
1
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'c> OutputAssertExt for &'c mut process::Command {
panic!("Failed to spawn {:?}: {}", self, err);
}
};
Assert::new(output).append_context("command", format!("{:?}", self))
Assert::new(output).append_context("command", format!("{self:?}"))
}
}

Expand Down Expand Up @@ -1084,13 +1084,13 @@ impl fmt::Display for AssertError {
writeln!(f, "Command interrupted")
}
AssertReason::UnexpectedReturnCode { case_tree } => {
writeln!(f, "Unexpected return code, failed {}", case_tree)
writeln!(f, "Unexpected return code, failed {case_tree}")
}
AssertReason::UnexpectedStdout { case_tree } => {
writeln!(f, "Unexpected stdout, failed {}", case_tree)
writeln!(f, "Unexpected stdout, failed {case_tree}")
}
AssertReason::UnexpectedStderr { case_tree } => {
writeln!(f, "Unexpected stderr, failed {}", case_tree)
writeln!(f, "Unexpected stderr, failed {case_tree}")
}
}?;
write!(f, "{}", self.assert)
Expand Down
6 changes: 3 additions & 3 deletions src/bin/bin_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use std::process;

fn run() -> Result<(), Box<dyn Error>> {
if let Ok(text) = env::var("stdout") {
println!("{}", text);
println!("{text}");
}
if let Ok(text) = env::var("stderr") {
eprintln!("{}", text);
eprintln!("{text}");
}

if let Some(timeout) = env::var("sleep").ok().and_then(|s| s.parse().ok()) {
Expand All @@ -31,7 +31,7 @@ fn main() {
let code = match run() {
Ok(_) => 0,
Err(ref e) => {
write!(&mut io::stderr(), "{}", e).expect("writing to stderr won't fail");
write!(&mut io::stderr(), "{e}").expect("writing to stderr won't fail");
1
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Error for CargoError {}
impl fmt::Display for CargoError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(ref cause) = self.cause {
writeln!(f, "Cause: {}", cause)?;
writeln!(f, "Cause: {cause}")?;
}
Ok(())
}
Expand Down Expand Up @@ -222,7 +222,7 @@ pub fn cargo_bin<S: AsRef<str>>(name: S) -> path::PathBuf {
}

fn cargo_bin_str(name: &str) -> path::PathBuf {
let env_var = format!("CARGO_BIN_EXE_{}", name);
let env_var = format!("CARGO_BIN_EXE_{name}");
env::var_os(env_var)
.map(|p| p.into())
.unwrap_or_else(|| target_dir().join(format!("{}{}", name, env::consts::EXE_SUFFIX)))
Expand Down
2 changes: 1 addition & 1 deletion src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ impl<'c> OutputAssertExt for &'c mut Command {
let output = match self.output() {
Ok(output) => output,
Err(err) => {
panic!("Failed to spawn {:?}: {}", self, err);
panic!("Failed to spawn {self:?}: {err}");
}
};
let assert = Assert::new(output).append_context("command", format!("{:?}", self.cmd));
Expand Down
12 changes: 6 additions & 6 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl<'c> OutputOkExt for &'c mut process::Command {
if output.status.success() {
Ok(output)
} else {
let error = OutputError::new(output).set_cmd(format!("{:?}", self));
let error = OutputError::new(output).set_cmd(format!("{self:?}"));
Err(error)
}
}
Expand Down Expand Up @@ -266,8 +266,8 @@ enum OutputCause {
impl fmt::Display for OutputCause {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
OutputCause::Expected(ref e) => write!(f, "{:#}", e),
OutputCause::Unexpected(ref e) => write!(f, "{:#}", e),
OutputCause::Expected(ref e) => write!(f, "{e:#}"),
OutputCause::Unexpected(ref e) => write!(f, "{e:#}"),
}
}
}
Expand Down Expand Up @@ -369,9 +369,9 @@ fn format_bytes(data: &[u8], f: &mut impl fmt::Write) -> fmt::Result {
.as_bstr()
.lines_with_terminator()
.skip(LINES_MAX_START + lines_omitted);
writeln!(f, "<{} lines total>", lines_total)?;
writeln!(f, "<{lines_total} lines total>")?;
write_debug_bstrs(f, true, start_lines)?;
writeln!(f, "<{} lines omitted>", lines_omitted)?;
writeln!(f, "<{lines_omitted} lines omitted>")?;
write_debug_bstrs(f, true, end_lines)
} else if BYTES_MIN_OVERFLOW <= data.len() {
write!(
Expand Down Expand Up @@ -434,7 +434,7 @@ mod test {
fn format_bytes() {
let mut s = String::new();
for i in 0..80 {
s.push_str(&format!("{}\n", i));
s.push_str(&format!("{i}\n"));
}

let mut buf = String::new();
Expand Down
8 changes: 4 additions & 4 deletions tests/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn mod_example() {
.unwrap();
let mut cmd = bin_under_test.command();
let output = cmd.unwrap();
println!("{:?}", output);
println!("{output:?}");
}
}

Expand All @@ -43,20 +43,20 @@ fn mod_example() {
fn trait_example() {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap();
let output = cmd.unwrap();
println!("{:?}", output);
println!("{output:?}");
}

#[test]
#[should_panic] // No bin named `assert_cmd
fn cargo_bin_example_1() {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap();
let output = cmd.unwrap();
println!("{:?}", output);
println!("{output:?}");
}

#[test]
fn cargo_bin_example_2() {
let mut cmd = Command::cargo_bin("bin_fixture").unwrap();
let output = cmd.unwrap();
println!("{:?}", output);
println!("{output:?}");
}
Loading