From 3272dadec09175636c2cec312bac24a725135c43 Mon Sep 17 00:00:00 2001 From: DevSabb Date: Fri, 4 Feb 2022 15:39:26 -0500 Subject: [PATCH 1/2] include io-blksize parameter --- src/uu/split/src/split.rs | 10 ++++++++++ tests/by-util/test_split.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index a0595981036..088120601a8 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -32,6 +32,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"; @@ -139,6 +142,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 8e61c5153f3..3cf982f1436 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -440,3 +440,31 @@ fn test_number() { assert_eq!(file_read("xad"), "pqrst"); assert_eq!(file_read("xae"), "uvwxyz"); } + +#[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"; + 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)); +} From 149ce6c78aa0fe054c8928bc06ba26a1e6b769bf Mon Sep 17 00:00:00 2001 From: DevSabb Date: Fri, 4 Feb 2022 16:13:38 -0500 Subject: [PATCH 2/2] format changes for including io-blksize --- src/uu/split/src/split.rs | 4 ++-- tests/by-util/test_split.rs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/uu/split/src/split.rs b/src/uu/split/src/split.rs index 088120601a8..1ff3273d815 100644 --- a/src/uu/split/src/split.rs +++ b/src/uu/split/src/split.rs @@ -32,7 +32,7 @@ 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 ---io-blksize parameter is consumed and ignored. //The parameter is included to make GNU coreutils tests pass. static OPT_IO_BLKSIZE: &str = "-io-blksize"; @@ -147,7 +147,7 @@ pub fn uu_app<'a>() -> App<'a> { .long(OPT_IO_BLKSIZE) .alias(OPT_IO_BLKSIZE) .takes_value(true) - .hide(true) + .hide(true), ) .arg( Arg::new(ARG_INPUT) diff --git a/tests/by-util/test_split.rs b/tests/by-util/test_split.rs index 3cf982f1436..0e8afbbd521 100644 --- a/tests/by-util/test_split.rs +++ b/tests/by-util/test_split.rs @@ -449,7 +449,8 @@ fn test_split_number_with_io_blksize() { at.open(f).read_to_string(&mut s).unwrap(); s }; - ucmd.args(&["-n", "5", "asciilowercase.txt", "---io-blksize", "1024"]).succeeds(); + 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"); @@ -460,7 +461,7 @@ fn test_split_number_with_io_blksize() { #[test] fn test_split_default_with_io_blksize() { let (at, mut ucmd) = at_and_ucmd!(); - let name = "split_default"; + let name = "split_default_with_io_blksize"; RandomFile::new(&at, name).add_lines(2000); ucmd.args(&[name, "---io-blksize", "2M"]).succeeds();