Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update from _rust template #98

Merged
merged 9 commits into from
Sep 27, 2024
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 @@ -6,10 +6,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 @@ -25,7 +25,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
6 changes: 3 additions & 3 deletions src/bin/bin_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,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 @@ -25,7 +25,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/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ impl fmt::Display for CargoError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "Cargo command failed: {}", self.kind)?;
if let Some(ref context) = self.context {
writeln!(f, "{}", context)?;
writeln!(f, "{context}")?;
}
if let Some(ref cause) = self.cause {
writeln!(f, "Cause: {}", cause)?;
writeln!(f, "Cause: {cause}")?;
}
Ok(())
}
Expand Down
10 changes: 5 additions & 5 deletions src/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ pub(crate) fn log_message(msg: &Message<'_>) {
.map(|s| s.as_ref())
.unwrap_or_else(|| comp.message.message.as_ref());
match comp.message.level {
diagnostic::DiagnosticLevel::Ice => eprintln!("{}", content),
diagnostic::DiagnosticLevel::Error => eprintln!("{}", content),
diagnostic::DiagnosticLevel::Warning => eprintln!("{}", content),
diagnostic::DiagnosticLevel::Note => eprintln!("{}", content),
diagnostic::DiagnosticLevel::Help => eprintln!("{}", content),
diagnostic::DiagnosticLevel::Ice => eprintln!("{content}"),
diagnostic::DiagnosticLevel::Error => eprintln!("{content}"),
diagnostic::DiagnosticLevel::Warning => eprintln!("{content}"),
diagnostic::DiagnosticLevel::Note => eprintln!("{content}"),
diagnostic::DiagnosticLevel::Help => eprintln!("{content}"),
#[cfg(not(feature = "strict_unstable"))]
_ => eprintln!("Unknown message: {:#?}", msg),
}
Expand Down
8 changes: 2 additions & 6 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,8 @@ fn extract_binary_path(
if bins.is_empty() {
return Err(CargoError::new(ErrorKind::CommandFailed).set_context("No binaries in crate"));
} else if bins.len() != 1 {
return Err(
CargoError::new(ErrorKind::CommandFailed).set_context(std::format!(
"Ambiguous which binary is intended: {:?}",
bins
)),
);
return Err(CargoError::new(ErrorKind::CommandFailed)
.set_context(std::format!("Ambiguous which binary is intended: {bins:?}")));
}
Ok(bins.into_iter().next().expect("already validated"))
}
8 changes: 4 additions & 4 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn test_fixture(name: &str) {
let temp = tempfile::TempDir::new().unwrap();

let msgs = escargot::CargoBuild::new()
.manifest_path(format!("tests/testsuite/fixtures/{}/Cargo.toml", name))
.manifest_path(format!("tests/testsuite/fixtures/{name}/Cargo.toml"))
.current_release()
.current_target()
.target_dir(temp.path())
Expand All @@ -12,8 +12,8 @@ fn test_fixture(name: &str) {
let raw_msg = msg.unwrap();
let msg = raw_msg.decode();
match msg {
Ok(msg) => println!("{:#?}", msg),
Err(err) => panic!("{}\nmsg=`{:#?}`", err, raw_msg),
Ok(msg) => println!("{msg:#?}"),
Err(err) => panic!("{err}\nmsg=`{raw_msg:#?}`"),
}
}
}
Expand Down Expand Up @@ -62,7 +62,7 @@ fn test_error() {
for msg in &msgs[0..error_idx] {
let msg = msg.as_ref().unwrap();
let msg = msg.decode().unwrap();
println!("{:#?}", msg);
println!("{msg:#?}");
}
assert!(msgs[error_idx].is_err());
println!("```{}```", msgs[error_idx].as_ref().err().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fn test_fixture(name: &str) {
let temp = tempfile::TempDir::new().unwrap();

let cmd = escargot::CargoBuild::new()
.manifest_path(format!("tests/testsuite/fixtures/{}/Cargo.toml", name))
.manifest_path(format!("tests/testsuite/fixtures/{name}/Cargo.toml"))
.current_release()
.current_target()
.target_dir(temp.path())
Expand Down
Loading