Skip to content

Commit

Permalink
Fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Flakebi committed Jan 13, 2023
1 parent ae901ec commit ceaaced
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
25 changes: 11 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,14 @@ impl<'a, 'list> RunTestListState<'a, 'list> {
// Create a temporary file for the test list
let mut temp_file = NamedTempFile::new().map_err(|e| DeqpErrorWithOutput {
error: DeqpError::StartError(format!(
"Failed to create temporary file for test list: {}",
e
"Failed to create temporary file for test list: {e}"
)),
stdout: String::new(),
})?;
for t in self.tests {
writeln!(&mut temp_file, "{}", t).map_err(|e| DeqpErrorWithOutput {
writeln!(&mut temp_file, "{t}").map_err(|e| DeqpErrorWithOutput {
error: DeqpError::StartError(format!(
"Failed to write temporary file for test list: {}",
e
"Failed to write temporary file for test list: {e}"
)),
stdout: String::new(),
})?;
Expand Down Expand Up @@ -609,7 +607,7 @@ impl<'a, 'list> RunTestListState<'a, 'list> {
let dir_name = if i == 0 {
failed_test.to_string()
} else {
format!("{}-{}", failed_test, i)
format!("{failed_test}-{i}")
};
let new_dir = dir.join(&dir_name);
if !new_dir.exists() {
Expand Down Expand Up @@ -647,7 +645,7 @@ impl<'a, 'list> RunTestListState<'a, 'list> {

// Write tests
for t in self.tests {
writeln!(&mut f, "{}", t)?;
writeln!(&mut f, "{t}")?;
}
Ok(())
})() {
Expand Down Expand Up @@ -729,7 +727,7 @@ impl<'a, 'list> RunTestListState<'a, 'list> {
fn handle_test_start(&mut self, name: &str) -> Vec<RunTestListEvent<'a, 'list>> {
trace!(self.logger, "Test started"; "test" => name);
let next_test = self.last_finished.map(|i| i + 1).unwrap_or_default();
if let Some(i) = (&self.tests[next_test..]).iter().position(|t| t == &name) {
if let Some(i) = self.tests[next_test..].iter().position(|t| t == &name) {
self.cur_test = Some((next_test + i, OffsetDateTime::now_utc()));
self.get_missing(i)
} else {
Expand Down Expand Up @@ -1122,14 +1120,14 @@ pub async fn sort_with_deqp<S: AsRef<OsStr>>(
// Create a temporary file for the input test list
let mut temp_file = NamedTempFile::new().map_err(DeqpSortError::TempFile)?;
for t in tests {
writeln!(&mut temp_file, "{}", t).map_err(DeqpSortError::WriteFailed)?;
writeln!(&mut temp_file, "{t}").map_err(DeqpSortError::WriteFailed)?;
}

let mut args = args.iter().map(|s| s.as_ref()).collect::<Vec<_>>();
args.push(temp_file.path().as_os_str());
args.push("--deqp-runmode=stdout-caselist".as_ref());
trace!(logger, "Run deqp for sorting"; "args" => ?args);
let mut cmd = Command::new(&args[0]);
let mut cmd = Command::new(args[0]);
cmd.args(&args[1..])
.stdout(Stdio::piped())
.stderr(Stdio::piped())
Expand Down Expand Up @@ -1445,8 +1443,7 @@ pub async fn run_tests_parallel<'a>(
));
// Show fails and crashes on progress bar
pb.set_message(format!(
"; fails: {}, crashes: {}",
fails, crashes
"; fails: {fails}, crashes: {crashes}"
));
pb.tick();
} else {
Expand Down Expand Up @@ -1572,7 +1569,7 @@ mod tests {

let mut summary = Summary::default();
run_tests_parallel(
&logger,
logger,
tests,
&mut summary,
&run_options,
Expand All @@ -1589,7 +1586,7 @@ mod tests {
);
for (t, r) in expected {
if let Some(r2) = summary.0.get(t) {
assert_eq!(r2.0.result, *r, "Test result does not match for test {}", t);
assert_eq!(r2.0.result, *r, "Test result does not match for test {t}");
} else {
panic!("Test {} has no result but expected {:?}", t, r);
}
Expand Down
2 changes: 1 addition & 1 deletion src/slog_pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Decorator for ProgressBarDecorator {
crate::PROGRESS_BAR.println(String::from_utf8(rec).map_err(|e| {
std::io::Error::new(
std::io::ErrorKind::Other,
format!("Cannot convert log message to string: {}", e),
format!("Cannot convert log message to string: {e}"),
)
})?);
Ok(())
Expand Down
20 changes: 10 additions & 10 deletions src/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ pub struct SummaryEntry<'a> {
}

/// Write summary csv and xml file.
pub fn write_summary<'a>(
pub fn write_summary(
logger: &Logger,
tests: &[&'a str],
tests: &[&str],
summary: &Summary,
fail_dir: Option<&Path>,
csv_file: Option<&Path>,
Expand Down Expand Up @@ -79,9 +79,9 @@ pub fn write_summary<'a>(
Ok(())
}

pub fn create_xml_summary<'a>(
pub fn create_xml_summary(
logger: &Logger,
tests: &[&'a str],
tests: &[&str],
summary: &Summary,
fail_dir: Option<&Path>,
) -> Result<junit_report::Report, WriteSummaryError> {
Expand Down Expand Up @@ -171,7 +171,7 @@ pub fn create_xml_summary<'a>(
"aborted",
junit_report::Duration::seconds(0),
"NotRun",
&format!("{} test cases were not run", has_not_run),
&format!("{has_not_run} test cases were not run"),
));
}

Expand Down Expand Up @@ -242,7 +242,7 @@ mod tests {
async fn test_b() -> Result<()> {
let report = check_tests(&["test/test-runner.sh", "logs/b", "logs/b-err", "1"]).await?;
let count: usize = report.testsuites().iter().map(|s| s.testcases.len()).sum();
println!("{:?}", report);
println!("{report:?}");
assert_eq!(count, 1, "Test case count does not match");
let test = &report.testsuites()[0].testcases[0];
assert_eq!(test.name, "aborted");
Expand All @@ -255,7 +255,7 @@ mod tests {
async fn test_d() -> Result<()> {
let report = check_tests(&["test/test-runner.sh", "logs/d", "/dev/null", "1"]).await?;
let count: usize = report.testsuites().iter().map(|s| s.testcases.len()).sum();
println!("{:?}", report);
println!("{report:?}");
assert_eq!(count, 2, "Test case count does not match");
let test = &report.testsuites()[0].testcases[0];
assert_eq!(test.name, "dEQP-VK.tessellation.primitive_discard.triangles_fractional_even_spacing_cw_point_mode");
Expand All @@ -268,7 +268,7 @@ mod tests {
async fn test_d_fatal() -> Result<()> {
let report = check_tests(&["test/test-runner.sh", "logs/d", "logs/d-err", "1"]).await?;
let count: usize = report.testsuites().iter().map(|s| s.testcases.len()).sum();
println!("{:?}", report);
println!("{report:?}");
assert_eq!(count, 2, "Test case count does not match");
let test = &report.testsuites()[0].testcases[0];
assert_eq!(test.name, "dEQP-VK.tessellation.primitive_discard.triangles_fractional_even_spacing_cw_point_mode");
Expand All @@ -281,7 +281,7 @@ mod tests {
async fn test_timeout() -> Result<()> {
let report = check_tests(&["test/test-timeout.sh", "logs/d", "/dev/null", "1"]).await?;
let count: usize = report.testsuites().iter().map(|s| s.testcases.len()).sum();
println!("{:?}", report);
println!("{report:?}");
assert_eq!(count, 2, "Test case count does not match");
let test = &report.testsuites()[0].testcases[0];
assert_eq!(test.name, "dEQP-VK.tessellation.primitive_discard.triangles_fractional_even_spacing_cw_point_mode");
Expand All @@ -296,7 +296,7 @@ mod tests {
&["test/bisect-test-runner.sh", "dEQP-VK.tessellation.primitive_discard.triangles_fractional_odd_spacing_ccw_valid_levels", "logs/d", "/dev/null", "1", "logs/a", "dev/null", "0"],
).await?;
let count: usize = report.testsuites().iter().map(|s| s.testcases.len()).sum();
println!("{:?}", report);
println!("{report:?}");
assert_eq!(count, 1, "Test case count does not match");
let test = &report.testsuites()[0].testcases[0];
assert_eq!(test.name, "dEQP-VK.tessellation.primitive_discard.triangles_fractional_even_spacing_cw_point_mode");
Expand Down

0 comments on commit ceaaced

Please sign in to comment.