Skip to content

Commit e2986e2

Browse files
committed
refactor(test_runner): inline format args
Ditto.
1 parent 851de5b commit e2986e2

File tree

10 files changed

+62
-90
lines changed

10 files changed

+62
-90
lines changed

src/r3_test_runner/src/driverinterface.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ impl TestDriver {
112112

113113
// Locate the test driver's crate
114114
let crate_path = driver_base_path.join(crate_name);
115-
log::debug!("driver.crate_name = {:?}", crate_name);
116-
log::debug!("driver.crate_path = {:?}", crate_path);
115+
log::debug!("driver.crate_name = {crate_name:?}");
116+
log::debug!("driver.crate_path = {crate_path:?}");
117117

118118
async move {
119119
if !crate_path.is_dir() {
@@ -158,7 +158,7 @@ impl TestDriver {
158158
return Err(TestDriverNewError::DriverMetadata(e));
159159
}
160160
};
161-
log::trace!("driver.meta = {:?}", meta);
161+
log::trace!("driver.meta = {meta:?}");
162162

163163
// Find the target directory
164164
let target_dir = {
@@ -191,7 +191,7 @@ impl TestDriver {
191191

192192
// Put generated linker scripts in a directory
193193
let linker_scripts = target.linker_scripts();
194-
log::debug!("linker_scripts = {:?}", linker_scripts);
194+
log::debug!("linker_scripts = {linker_scripts:?}");
195195
let link_dir =
196196
tempdir::TempDir::new("r3_test_runner").map_err(TestDriverNewError::TempDirError)?;
197197

@@ -263,7 +263,7 @@ impl TestDriver {
263263
Ok(output_bytes) => {
264264
// Check the output
265265
let output_str = String::from_utf8_lossy(&output_bytes);
266-
log::debug!("Output (lossy UTF-8) = {:?}", output_str);
266+
log::debug!("Output (lossy UTF-8) = {output_str:?}");
267267

268268
if output_str.contains("!- TEST WAS SUCCESSFUL -!") {
269269
Ok(())
@@ -313,7 +313,7 @@ impl TestDriver {
313313
if exe_path.exists() {
314314
if let Err(e) = std::fs::remove_file(exe_path) {
315315
// Failure is non-fatal
316-
log::warn!("Failed to remove '{}': {}", exe_path.display(), e);
316+
log::warn!("Failed to remove '{}': {e}", exe_path.display());
317317
}
318318
}
319319

@@ -428,7 +428,7 @@ async fn debug_probe_program_and_get_output_until<P: AsRef<[u8]>>(
428428

429429
let num_bytes = tokio::select! {
430430
read_result = read_fut => {
431-
log::trace!("... `read` resolved to {:?}", read_result);
431+
log::trace!("... `read` resolved to {read_result:?}");
432432
read_result.unwrap_or(0)
433433
},
434434
_ = timeout_fut => {
@@ -489,7 +489,7 @@ async fn read_to_end_timeout(
489489

490490
let num_bytes = tokio::select! {
491491
read_result = read_fut => {
492-
log::trace!("... `read` resolved to {:?}", read_result);
492+
log::trace!("... `read` resolved to {read_result:?}");
493493
read_result.unwrap_or(0)
494494
},
495495
_ = &mut timeout_fut => {

src/r3_test_runner/src/main.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async fn main() {
2626
.init();
2727

2828
if let Err(e) = main_inner().await {
29-
log::error!("Command failed.\n{:?}", e);
29+
log::error!("Command failed.\n{e:?}");
3030
std::process::exit(1);
3131
}
3232
}
@@ -135,19 +135,19 @@ async fn main_inner() -> anyhow::Result<()> {
135135
// was built.
136136
let driver_base_path = {
137137
let manifest_dir = env!("CARGO_MANIFEST_DIR");
138-
log::debug!("CARGO_MANIFEST_DIR = {}", manifest_dir);
138+
log::debug!("CARGO_MANIFEST_DIR = {manifest_dir}");
139139
Path::new(manifest_dir)
140140
.parent()
141141
.expect("Couldn't get the parent of `CARGO_MANIFEST_DIR`")
142142
};
143143

144144
let target_arch = opt.target_arch.unwrap_or_else(|| opt.target.target_arch());
145-
log::debug!("target_arch = {}", target_arch);
145+
log::debug!("target_arch = {target_arch}");
146146

147147
let target_arch_opt = target_arch.build_opt().with_context(|| {
148148
format!("The target architecture '{target_arch}' is invalid or unsupported.")
149149
})?;
150-
log::debug!("target_arch_opt = {:?}", target_arch_opt);
150+
log::debug!("target_arch_opt = {target_arch_opt:?}");
151151

152152
// Initialize the test driver interface
153153
let test_driver = driverinterface::TestDriver::new(
@@ -213,7 +213,7 @@ async fn main_inner() -> anyhow::Result<()> {
213213
}
214214

215215
let full_test_name = test_run.case.to_string();
216-
log::info!(" - {}", test_run);
216+
log::info!(" - {test_run}");
217217

218218
// Build the test driver
219219
test_driver
@@ -267,11 +267,11 @@ async fn main_inner() -> anyhow::Result<()> {
267267

268268
match test_result {
269269
Ok(()) => {
270-
log::info!("Test run '{}' was successful", test_run);
270+
log::info!("Test run '{test_run}' was successful");
271271
}
272272
Err(msg) => {
273273
// Test did run, but the result was failure.
274-
log::error!("Test run '{}' failed: {}", test_run, msg);
274+
log::error!("Test run '{test_run}' failed: {msg}");
275275
failed_tests.push(test_run.to_string());
276276
continue;
277277
}
@@ -289,13 +289,13 @@ async fn main_inner() -> anyhow::Result<()> {
289289
log::error!("Failed tests:");
290290

291291
for test_run_name in failed_tests {
292-
log::error!(" - {}", test_run_name);
292+
log::error!(" - {test_run_name}");
293293
}
294294

295295
if !tests_skipped_to_fail_fast.is_empty() {
296296
log::warn!("Skipped tests:");
297297
for test_run_name in tests_skipped_to_fail_fast {
298-
log::warn!(" - {}", test_run_name);
298+
log::warn!(" - {test_run_name}");
299299
}
300300
}
301301

src/r3_test_runner/src/targets/demux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl AsyncBufRead for Demux<'_> {
118118
Pin::new(&mut this.inner).consume(num_bytes);
119119
}
120120
Err(e) => {
121-
log::trace!("Ignoring error while outputting to stdout: {:?}", e);
121+
log::trace!("Ignoring error while outputting to stdout: {e:?}");
122122
// Ignore any I/O errors caused by stdout
123123
Pin::new(&mut this.inner).consume(payload_len);
124124
}

src/r3_test_runner/src/targets/jlink.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ impl DebugProbe for Fe310JLinkDebugProbe {
115115
let mut cmd = String::new();
116116
writeln!(cmd, "r").unwrap();
117117
for (path, (_, offset)) in section_files.iter().zip(regions.iter()) {
118-
writeln!(cmd, "loadbin \"{}\" 0x{:08x}", path.display(), offset).unwrap();
118+
writeln!(cmd, "loadbin \"{}\" 0x{offset:08x}", path.display()).unwrap();
119119
}
120120
writeln!(cmd, "setpc 0x{entry:x}").unwrap();
121121
writeln!(cmd, "g").unwrap();
122122
writeln!(cmd, "q").unwrap();
123123

124124
// Flash the program and reset the chip
125125
// (`probe-rs` doesn't support FE310-based boards at this time)
126-
log::debug!("Launching JLinkExe and executing '{:?}'", cmd);
126+
log::debug!("Launching JLinkExe and executing '{cmd:?}'");
127127
subprocess::CmdBuilder::new("JLinkExe")
128128
.args([
129129
"-device",

src/r3_test_runner/src/targets/kflash.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl DebugProbe for KflashDebugProbe {
222222
}
223223

224224
// Boot the program
225-
log::debug!("Booting from 0x{:08x}", entry);
225+
log::debug!("Booting from 0x{entry:08x}");
226226
boot(&mut self.serial, entry as u32).await?;
227227

228228
// Now, pass the channel to the caller
@@ -310,7 +310,7 @@ async fn maix_enter_isp_mode(
310310
let serial_inner = serial.get_mut();
311311
log::debug!("Trying to put the chip into ISP mode");
312312
for cmd in cmds {
313-
log::trace!("Performing the command {:?}", cmd);
313+
log::trace!("Performing the command {cmd:?}");
314314
match cmd {
315315
BootCmd::Dtr(b) => {
316316
serial_inner
@@ -348,8 +348,7 @@ async fn maix_enter_isp_mode(
348348
match tokio::time::timeout(COMM_TIMEOUT, slip::read_frame(serial)).await {
349349
Ok(Ok(frame)) => {
350350
log::trace!(
351-
"Received a packet: {:?} The chip probably successfully entered ISP mode",
352-
frame
351+
"Received a packet: {frame:?} The chip probably successfully entered ISP mode",
353352
);
354353
}
355354
Ok(Err(e)) => return Err(e.into()),
@@ -372,10 +371,9 @@ async fn flash_dataframe(
372371
let chunk_addr = address + (i * CHUNK_LEN) as u32;
373372

374373
log::debug!(
375-
"Programming the range {:?}/{:?} at 0x{:x} ({}%)",
374+
"Programming the range {:?}/{:?} at 0x{chunk_addr:x} ({}%)",
376375
(i * CHUNK_LEN)..(i * CHUNK_LEN + chunk.len()),
377376
data.len(),
378-
chunk_addr,
379377
i * CHUNK_LEN * 100 / data.len(),
380378
);
381379

@@ -416,7 +414,7 @@ async fn flash_dataframe(
416414
}
417415
}
418416

419-
log::trace!("Got {:?}. Retrying...", reason);
417+
log::trace!("Got {reason:?}. Retrying...");
420418
}
421419

422420
if let Some(error) = error {
@@ -502,7 +500,7 @@ async fn read_to_end_and_discard(
502500
let mut buf = [0u8; 256];
503501
loop {
504502
let num_bytes = reader.read(&mut buf).await?;
505-
log::trace!("Discarding {} byte(s)", num_bytes);
503+
log::trace!("Discarding {num_bytes} byte(s)");
506504
}
507505
}
508506

src/r3_test_runner/src/targets/probe_rs.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,14 @@ pub async fn attach_rtt(
169169
.await
170170
.unwrap();
171171
if let Some(x) = addr {
172-
log::debug!("Found the RTT header at 0x{:x}", x);
172+
log::debug!("Found the RTT header at 0x{x:x}");
173173
probe_rs_rtt::ScanRegion::Exact(x as u32)
174174
} else {
175175
probe_rs_rtt::ScanRegion::Ram
176176
}
177177
}
178178
Err(e) => {
179-
log::warn!(
180-
"Couldn't read the executable to find the RTT header: {:?}",
181-
e
182-
);
179+
log::warn!("Couldn't read the executable to find the RTT header: {e:?}");
183180
probe_rs_rtt::ScanRegion::Ram
184181
}
185182
};
@@ -233,10 +230,7 @@ fn find_rtt_symbol(elf_bytes: &[u8]) -> Option<u64> {
233230
let elf = match goblin::elf::Elf::parse(elf_bytes) {
234231
Ok(elf) => elf,
235232
Err(e) => {
236-
log::warn!(
237-
"Couldn't parse the executable to find the RTT header: {:?}",
238-
e
239-
);
233+
log::warn!("Couldn't parse the executable to find the RTT header: {e:?}");
240234
return None;
241235
}
242236
};
@@ -267,7 +261,7 @@ impl<'a, 'probe> CoreHaltGuard<'a, 'probe> {
267261
impl Drop for CoreHaltGuard<'_, '_> {
268262
fn drop(&mut self) {
269263
if let Err(e) = self.core.run() {
270-
log::warn!("Failed to restart the core (ignored): {:?}", e);
264+
log::warn!("Failed to restart the core (ignored): {e:?}");
271265
}
272266
}
273267
}

0 commit comments

Comments
 (0)