Skip to content

Commit

Permalink
Some clippy fixes in tests
Browse files Browse the repository at this point in the history
done with: cargo +nightly clippy --tests --fix --allow-dirty -- -W clippy::pedantic
  • Loading branch information
sylvestre committed Apr 9, 2024
1 parent 6060b5e commit 1c77f97
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions tests/by-util/test_free.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn test_invalid_arg() {
#[test]
fn test_free() {
let result = new_ucmd!().succeeds();
assert!(result.stdout_str().contains("Mem:"))
assert!(result.stdout_str().contains("Mem:"));
}

#[test]
Expand All @@ -44,7 +44,7 @@ fn test_free_column_format() {
assert_eq!(free_result.len(), 207);

// Check the format for each line output
let mut free_lines = free_result.split("\n");
let mut free_lines = free_result.split('\n');
for re in re_list {
assert!(re.is_match(free_lines.next().unwrap()));
}
Expand All @@ -69,7 +69,7 @@ fn test_free_wide_column_format() {
assert_eq!(free_result.len(), 231);

// Check the format for each line output
let mut free_lines = free_result.split("\n");
let mut free_lines = free_result.split('\n');
for re in re_list {
assert!(re.is_match(free_lines.next().unwrap()));
}
Expand Down
4 changes: 2 additions & 2 deletions tests/by-util/test_w.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ fn test_output_format() {
let output_lines = cmd.stdout_str().lines();

for line in output_lines {
let line_vec: Vec<String> = line.split_whitespace().map(|s| String::from(s)).collect();
let line_vec: Vec<String> = line.split_whitespace().map(String::from).collect();
// Check the time formatting, this should be the third entry in list
// For now, we are just going to check that that length of time is 5 and it has a colon, else
// it is possible that a time can look like Fri13, so it can start with a letter and end
// with a number
assert!(
(line_vec[2].contains(":") && line_vec[2].chars().count() == 5)
(line_vec[2].contains(':') && line_vec[2].chars().count() == 5)
|| (line_vec[2].starts_with(char::is_alphabetic)
&& line_vec[2].ends_with(char::is_numeric)
&& line_vec[2].chars().count() == 5)
Expand Down
8 changes: 4 additions & 4 deletions tests/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ fn read_scenario_fixture<S: AsRef<OsStr>>(tmpd: &Option<Rc<TempDir>>, file_rel_p
/// within a struct which has convenience assertion functions about those outputs
#[derive(Debug, Clone)]
pub struct CmdResult {
/// bin_path provided by `TestScenario` or `UCommand`
/// `bin_path` provided by `TestScenario` or `UCommand`
bin_path: PathBuf,
/// util_name provided by `TestScenario` or `UCommand`
/// `util_name` provided by `TestScenario` or `UCommand`
util_name: Option<String>,
//tmpd is used for convenience functions for asserts against fixtures
tmpd: Option<Rc<TempDir>>,
Expand Down Expand Up @@ -1563,15 +1563,15 @@ impl UCommand {

/// Spawns the command, feeds the stdin if any, waits for the result
/// and returns a command result.
/// It is recommended that you instead use succeeds() or fails()
/// It is recommended that you instead use `succeeds()` or `fails()`
pub fn run(&mut self) -> CmdResult {
self.run_no_wait().wait().unwrap()
}

/// Spawns the command, feeding the passed in stdin, waits for the result
/// and returns a command result.
/// It is recommended that, instead of this, you use a combination of `pipe_in()`
/// with succeeds() or fails()
/// with `succeeds()` or `fails()`
pub fn run_piped_stdin<T: Into<Vec<u8>>>(&mut self, input: T) -> CmdResult {
self.pipe_in(input).run()
}
Expand Down

0 comments on commit 1c77f97

Please sign in to comment.