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

clippy: fix warnings in tests #5362

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,6 @@ fn test_cp_preserve_links_case_7() {
.arg("dest")
.fails()
.stderr_contains("not replacing");
();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahah :)


assert!(at.dir_exists("dest"));
assert!(at.plus("dest").join("f").exists());
Expand Down
40 changes: 20 additions & 20 deletions tests/by-util/test_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,17 +438,17 @@ fn test_split_obs_lines_within_combined_shorts() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let name = "obs-lines-within-shorts";
RandomFile::new(&at, name).add_lines(400);
RandomFile::new(at, name).add_lines(400);

scene
.ucmd()
.args(&["-x200de", name])
.succeeds()
.no_stderr()
.no_stdout();
let glob = Glob::new(&at, ".", r"x\d\d$");
let glob = Glob::new(at, ".", r"x\d\d$");
assert_eq!(glob.count(), 2);
assert_eq!(glob.collate(), at.read_bytes(name))
assert_eq!(glob.collate(), at.read_bytes(name));
}

/// Test for obsolete lines option as part of combined short options with tailing suffix length with value
Expand All @@ -470,17 +470,17 @@ fn test_split_obs_lines_starts_combined_shorts() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let name = "obs-lines-starts-shorts";
RandomFile::new(&at, name).add_lines(400);
RandomFile::new(at, name).add_lines(400);

scene
.ucmd()
.args(&["-200xd", name])
.succeeds()
.no_stderr()
.no_stdout();
let glob = Glob::new(&at, ".", r"x\d\d$");
let glob = Glob::new(at, ".", r"x\d\d$");
assert_eq!(glob.count(), 2);
assert_eq!(glob.collate(), at.read_bytes(name))
assert_eq!(glob.collate(), at.read_bytes(name));
}

/// Test for using both obsolete lines (standalone) option and short/long lines option simultaneously
Expand Down Expand Up @@ -585,17 +585,17 @@ fn test_split_multiple_obs_lines_standalone() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let name = "multiple-obs-lines";
RandomFile::new(&at, name).add_lines(400);
RandomFile::new(at, name).add_lines(400);

scene
.ucmd()
.args(&["-3000", "-200", name])
.succeeds()
.no_stderr()
.no_stdout();
let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$");
let glob = Glob::new(at, ".", r"x[[:alpha:]][[:alpha:]]$");
assert_eq!(glob.count(), 2);
assert_eq!(glob.collate(), at.read_bytes(name))
assert_eq!(glob.collate(), at.read_bytes(name));
}

/// Test for using more than one obsolete lines option within combined shorts
Expand All @@ -605,17 +605,17 @@ fn test_split_multiple_obs_lines_within_combined() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
let name = "multiple-obs-lines";
RandomFile::new(&at, name).add_lines(400);
RandomFile::new(at, name).add_lines(400);

scene
.ucmd()
.args(&["-d5000x", "-e200d", name])
.succeeds()
.no_stderr()
.no_stdout();
let glob = Glob::new(&at, ".", r"x\d\d$");
let glob = Glob::new(at, ".", r"x\d\d$");
assert_eq!(glob.count(), 2);
assert_eq!(glob.collate(), at.read_bytes(name))
assert_eq!(glob.collate(), at.read_bytes(name));
}

/// Test for using both obsolete lines option within combined shorts with conflicting -n option simultaneously
Expand Down Expand Up @@ -1543,8 +1543,8 @@ fn test_split_separator_nul_lines() {
ucmd.args(&["--lines=2", "-t", "\\0", "separator_nul.txt"])
.succeeds();

assert_eq!(file_read(&at, "xaa"), "1\02\0");
assert_eq!(file_read(&at, "xab"), "3\04\0");
assert_eq!(file_read(&at, "xaa"), "1\x002\0");
assert_eq!(file_read(&at, "xab"), "3\x004\0");
assert_eq!(file_read(&at, "xac"), "5\0");
assert!(!at.plus("xad").exists());
}
Expand All @@ -1555,8 +1555,8 @@ fn test_split_separator_nul_line_bytes() {
ucmd.args(&["--line-bytes=4", "-t", "\\0", "separator_nul.txt"])
.succeeds();

assert_eq!(file_read(&at, "xaa"), "1\02\0");
assert_eq!(file_read(&at, "xab"), "3\04\0");
assert_eq!(file_read(&at, "xaa"), "1\x002\0");
assert_eq!(file_read(&at, "xab"), "3\x004\0");
assert_eq!(file_read(&at, "xac"), "5\0");
assert!(!at.plus("xad").exists());
}
Expand All @@ -1567,8 +1567,8 @@ fn test_split_separator_nul_number_l() {
ucmd.args(&["--number=l/3", "--separator=\\0", "separator_nul.txt"])
.succeeds();

assert_eq!(file_read(&at, "xaa"), "1\02\0");
assert_eq!(file_read(&at, "xab"), "3\04\0");
assert_eq!(file_read(&at, "xaa"), "1\x002\0");
assert_eq!(file_read(&at, "xab"), "3\x004\0");
assert_eq!(file_read(&at, "xac"), "5\0");
assert!(!at.plus("xad").exists());
}
Expand All @@ -1579,8 +1579,8 @@ fn test_split_separator_nul_number_r() {
ucmd.args(&["--number=r/3", "--separator=\\0", "separator_nul.txt"])
.succeeds();

assert_eq!(file_read(&at, "xaa"), "1\04\0");
assert_eq!(file_read(&at, "xab"), "2\05\0");
assert_eq!(file_read(&at, "xaa"), "1\x004\0");
assert_eq!(file_read(&at, "xab"), "2\x005\0");
assert_eq!(file_read(&at, "xac"), "3\0");
assert!(!at.plus("xad").exists());
}
Expand Down
17 changes: 14 additions & 3 deletions tests/by-util/test_tee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
use crate::common::util::TestScenario;
use std::fmt::Write;

// tests for basic tee functionality.
// inspired by:
Expand Down Expand Up @@ -74,7 +75,10 @@ fn test_tee_append() {
fn test_tee_no_more_writeable_1() {
// equals to 'tee /dev/full out2 <multi_read' call
let (at, mut ucmd) = at_and_ucmd!();
let content = (1..=10).map(|x| format!("{x}\n")).collect::<String>();
let content = (1..=10).fold(String::new(), |mut output, x| {
let _ = writeln!(output, "{x}");
output
});
let file_out = "tee_file_out";

ucmd.arg("/dev/full")
Expand All @@ -94,7 +98,10 @@ fn test_tee_no_more_writeable_2() {
// but currently there is no way to redirect stdout to /dev/full
// so this test is disabled
let (_at, mut ucmd) = at_and_ucmd!();
let _content = (1..=10).map(|x| format!("{x}\n")).collect::<String>();
let _content = (1..=10).fold(String::new(), |mut output, x| {
let _ = writeln!(output, "{x}");
output
});
let file_out_a = "tee_file_out_a";
let file_out_b = "tee_file_out_b";

Expand All @@ -114,6 +121,7 @@ fn test_tee_no_more_writeable_2() {
mod linux_only {
use crate::common::util::{AtPath, TestScenario, UCommand};

use std::fmt::Write;
use std::fs::File;
use std::process::{Output, Stdio};

Expand All @@ -135,7 +143,10 @@ mod linux_only {
}

fn run_tee(proc: &mut UCommand) -> (String, Output) {
let content = (1..=100_000).map(|x| format!("{x}\n")).collect::<String>();
let content = (1..=100_000).fold(String::new(), |mut output, x| {
let _ = writeln!(output, "{x}");
output
});

#[allow(deprecated)]
let output = proc
Expand Down
Loading