Skip to content

Commit

Permalink
build: Use inlined variables in format strings
Browse files Browse the repository at this point in the history
These changes are suggested by Clippy.

Signed-off-by: Akira Moroo <retrage01@gmail.com>
  • Loading branch information
retrage committed Feb 12, 2023
1 parent 3dd7514 commit 246e418
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 34 deletions.
20 changes: 10 additions & 10 deletions src/fat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ mod tests {
let len = d.len();
let mut fs = crate::fat::Filesystem::new(&d, 0, len);
fs.init().expect("Error initialising filesystem");
let path = format!("/A/B/C/{}", v);
let path = format!("/A/B/C/{v}");
let mut f: crate::fat::File = fs
.open(&path)
.expect("Error opening file")
Expand All @@ -956,7 +956,7 @@ mod tests {
Err(super::Error::EndOfFile) => {
break;
}
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
}
}

Expand All @@ -979,7 +979,7 @@ mod tests {
let len = d.len();
let mut fs = crate::fat::Filesystem::new(&d, 0, len);
fs.init().expect("Error initialising filesystem");
let path = format!("/A/B/C/{}", v);
let path = format!("/A/B/C/{v}");
let mut f: crate::fat::File = fs
.open(&path)
.expect("Error opening file")
Expand All @@ -998,7 +998,7 @@ mod tests {
Err(super::Error::EndOfFile) => {
break;
}
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
}
}

Expand All @@ -1015,7 +1015,7 @@ mod tests {
Err(super::Error::EndOfFile) => {
break;
}
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
}
}

Expand All @@ -1033,7 +1033,7 @@ mod tests {
Err(super::Error::EndOfFile) => {
break;
}
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
}
}
assert_eq!(bytes_so_far, f.size);
Expand All @@ -1054,10 +1054,10 @@ mod tests {
assert_eq!(f.sectors, 1_046_528);
assert_eq!(f.fat_type, super::FatType::FAT16);
}
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
}
}
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
}
}

Expand All @@ -1078,10 +1078,10 @@ mod tests {
assert_eq!(file.active_cluster, 166);
assert_eq!(file.size, 92789);
}
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
}
}
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
}
}

Expand Down
38 changes: 16 additions & 22 deletions src/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ mod tests {

Self {
guest_mac,
host_ip: format!("192.168.{}.1", counter),
guest_ip: format!("192.168.{}.2", counter),
tap_name: format!("fwtap{}", counter),
host_ip: format!("192.168.{counter}.1"),
guest_ip: format!("192.168.{counter}.2"),
tap_name: format!("fwtap{counter}"),
}
}
}
Expand Down Expand Up @@ -307,7 +307,7 @@ mod tests {
.output()
.expect("Expect device mapper nodes to be ready");

osdisk.osdisk_path = format!("/dev/mapper/{}", windows_snapshot);
osdisk.osdisk_path = format!("/dev/mapper/{windows_snapshot}");
osdisk.windows_snapshot_cow = windows_snapshot_cow;
osdisk.windows_snapshot = windows_snapshot;
}
Expand Down Expand Up @@ -379,24 +379,18 @@ mod tests {
);
}
Some(code) => {
eprintln!("\n\n==== child exit code: {} ====", code);
eprintln!("\n\n==== child exit code: {code} ====");
}
}

let mut stdout = fs::File::open(tmp_dir.path().join("stdout")).unwrap();
let mut buf = String::new();
stdout.read_to_string(&mut buf).unwrap();
eprintln!(
"\n\n==== Start child stdout ====\n\n{}\n\n==== End child stdout ====",
buf
);
eprintln!("\n\n==== Start child stdout ====\n\n{buf}\n\n==== End child stdout ====");
let mut stderr = fs::File::open(tmp_dir.path().join("stderr")).unwrap();
let mut buf = String::new();
stderr.read_to_string(&mut buf).unwrap();
eprintln!(
"\n\n==== Start child stderr ====\n\n{}\n\n==== End child stderr ====",
buf
);
eprintln!("\n\n==== Start child stderr ====\n\n{buf}\n\n==== End child stderr ====");

panic!("Test failed")
}
Expand Down Expand Up @@ -431,8 +425,8 @@ mod tests {
let mut counter = 0;
loop {
match (|| -> Result<(), SSHCommandError> {
let tcp = TcpStream::connect(format!("{}:22", ip))
.map_err(SSHCommandError::Connection)?;
let tcp =
TcpStream::connect(format!("{ip}:22")).map_err(SSHCommandError::Connection)?;
let mut sess = ssh2::Session::new().unwrap();
sess.set_tcp_stream(tcp);
sess.handshake().map_err(SSHCommandError::Handshake)?;
Expand Down Expand Up @@ -499,16 +493,16 @@ mod tests {
"--kernel",
"target/x86_64-unknown-none/release/hypervisor-fw",
"--disk",
&format!("path={}", os),
&format!("path={}", ci),
&format!("path={os}"),
&format!("path={ci}"),
"--net",
&format!("tap={},mac={}", net.tap_name, net.guest_mac),
]);

let stdout = fs::File::create(tmp_dir.path().join("stdout")).unwrap();
let stderr = fs::File::create(tmp_dir.path().join("stderr")).unwrap();

eprintln!("Spawning: {:?}", c);
eprintln!("Spawning: {c:?}");
c.stdout(Stdio::from(stdout))
.stderr(Stdio::from(stderr))
.spawn()
Expand Down Expand Up @@ -536,11 +530,11 @@ mod tests {
"-serial",
"stdio",
"-drive",
&format!("id=os,file={},if=none", os),
&format!("id=os,file={os},if=none"),
"-device",
"virtio-blk-pci,drive=os,disable-legacy=on",
"-drive",
&format!("id=ci,file={},if=none,format=raw", ci),
&format!("id=ci,file={ci},if=none,format=raw"),
"-device",
"virtio-blk-pci,drive=ci,disable-legacy=on",
"-m",
Expand All @@ -557,7 +551,7 @@ mod tests {
let stdout = fs::File::create(tmp_dir.path().join("stdout")).unwrap();
let stderr = fs::File::create(tmp_dir.path().join("stderr")).unwrap();

eprintln!("Spawning: {:?}", c);
eprintln!("Spawning: {c:?}");
c.stdout(Stdio::from(stdout))
.stderr(Stdio::from(stderr))
.spawn()
Expand Down Expand Up @@ -715,7 +709,7 @@ mod tests {
let stdout = fs::File::create(tmp_dir.path().join("stdout")).unwrap();
let stderr = fs::File::create(tmp_dir.path().join("stderr")).unwrap();

eprintln!("Spawning: {:?}", c);
eprintln!("Spawning: {c:?}");
let mut child = c
.stdout(Stdio::from(stdout))
.stderr(Stdio::from(stderr))
Expand Down
2 changes: 1 addition & 1 deletion src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ mod tests {

assert_eq!(
default_entry_path,
format!("/loader/entries/{}.conf", s).as_str()
format!("/loader/entries/{s}.conf").as_str()
);

let mut f: crate::fat::File = fs.open(default_entry_path).unwrap().try_into().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/part.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub mod tests {
assert_eq!(start, 2048);
assert_eq!(end, 1_048_575);
}
Err(e) => panic!("{:?}", e),
Err(e) => panic!("{e:?}"),
}
}
}

0 comments on commit 246e418

Please sign in to comment.