From 6d6371741af92c6fba48711a9b41b17dc898f370 Mon Sep 17 00:00:00 2001 From: DevSabb <97408111+DevSabb@users.noreply.github.com> Date: Mon, 14 Feb 2022 13:47:18 -0500 Subject: [PATCH] include io-blksize parameter (#3064) * include io-blksize parameter * format changes for including io-blksize Co-authored-by: DevSabb Co-authored-by: Sylvestre Ledru --- src/uu/split/src/split.rs | 10 ++++++++++ tests/by-util/test_split.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 57953ae27..29559f8b8 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -34,6 +34,9 @@ static OPT_NUMERIC_SUFFIXES: &str = "numeric-suffixes"; static OPT_SUFFIX_LENGTH: &str = "suffix-length"; static OPT_DEFAULT_SUFFIX_LENGTH: &str = "0"; static OPT_VERBOSE: &str = "verbose"; +//The ---io-blksize parameter is consumed and ignored. +//The parameter is included to make GNU coreutils tests pass. +static OPT_IO_BLKSIZE: &str = "-io-blksize"; static ARG_INPUT: &str = "input"; static ARG_PREFIX: &str = "prefix"; @@ -144,6 +147,13 @@ pub fn uu_app<'a>() -> App<'a> { .long(OPT_VERBOSE) .help("print a diagnostic just before each output file is opened"), ) + .arg( + Arg::new(OPT_IO_BLKSIZE) + .long(OPT_IO_BLKSIZE) + .alias(OPT_IO_BLKSIZE) + .takes_value(true) + .hide(true), + ) .arg( Arg::new(ARG_INPUT) .takes_value(true) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 0291d1f4a..35f96d2a3 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -449,6 +449,35 @@ fn test_number() { assert_eq!(file_read("xae"), "uvwxyz\n"); } +#[test] +fn test_split_number_with_io_blksize() { + let (at, mut ucmd) = at_and_ucmd!(); + let file_read = |f| { + let mut s = String::new(); + at.open(f).read_to_string(&mut s).unwrap(); + s + }; + ucmd.args(&["-n", "5", "asciilowercase.txt", "---io-blksize", "1024"]) + .succeeds(); + assert_eq!(file_read("xaa"), "abcde"); + assert_eq!(file_read("xab"), "fghij"); + assert_eq!(file_read("xac"), "klmno"); + assert_eq!(file_read("xad"), "pqrst"); + assert_eq!(file_read("xae"), "uvwxyz"); +} + +#[test] +fn test_split_default_with_io_blksize() { + let (at, mut ucmd) = at_and_ucmd!(); + let name = "split_default_with_io_blksize"; + RandomFile::new(&at, name).add_lines(2000); + ucmd.args(&[name, "---io-blksize", "2M"]).succeeds(); + + let glob = Glob::new(&at, ".", r"x[[:alpha:]][[:alpha:]]$"); + assert_eq!(glob.count(), 2); + assert_eq!(glob.collate(), at.read_bytes(name)); +} + #[test] fn test_invalid_suffix_length() { new_ucmd!()