diff --git a/.github/workflows/GnuTests.yml b/.github/workflows/GnuTests.yml index fedd6e4d5..f2b0ddd45 100644 --- a/.github/workflows/GnuTests.yml +++ b/.github/workflows/GnuTests.yml @@ -198,7 +198,7 @@ jobs: do if ! grep -Fxq ${LINE}<<<"${REF_ERROR}" then - echo "::error ::GNU test failed: ${LINE}. ${LINE} is passing on '${{ steps.vars.outputs.repo_default_branch }}'. Maybe you have to rebase?" + echo "::error ::GNU test error: ${LINE}. ${LINE} is passing on '${{ steps.vars.outputs.repo_default_branch }}'. Maybe you have to rebase?" have_new_failures="true" fi done diff --git a/Cargo.lock b/Cargo.lock index 69a83941b..e676db6c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -273,9 +273,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "3.1.2" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1506b87ee866f7a53a5131f7b31fba656170d797e873d0609884cfd56b8bbda8" +checksum = "1d7ca9141e27e6ebc52e3c378b0c07f3cea52db46ed1cc5861735fb697b56356" dependencies = [ "clap 3.1.12", ] @@ -1021,9 +1021,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.124" +version = "0.2.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" +checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b" [[package]] name = "libloading" @@ -1623,9 +1623,9 @@ dependencies = [ [[package]] name = "retain_mut" -version = "0.1.2" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53552c6c49e1e13f1a203ef0080ab3bbef0beb570a528993e83df057a9d9bba1" +checksum = "8c31b5c4033f8fdde8700e4657be2c497e7288f01515be52168c631e2e4d4086" [[package]] name = "rlimit" diff --git a/src/uu/chmod/Cargo.toml b/src/uu/chmod/Cargo.toml index 9fab6011e..df0b089fa 100644 --- a/src/uu/chmod/Cargo.toml +++ b/src/uu/chmod/Cargo.toml @@ -16,7 +16,7 @@ path = "src/chmod.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs", "mode"] } [[bin]] diff --git a/src/uu/cp/Cargo.toml b/src/uu/cp/Cargo.toml index 9e1141650..f9036101a 100644 --- a/src/uu/cp/Cargo.toml +++ b/src/uu/cp/Cargo.toml @@ -21,7 +21,7 @@ path = "src/cp.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } filetime = "0.2" -libc = "0.2.124" +libc = "0.2.125" quick-error = "2.0.1" selinux = { version="0.2", optional=true } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms", "mode"] } diff --git a/src/uu/hostid/Cargo.toml b/src/uu/hostid/Cargo.toml index 0a2948459..d29160b21 100644 --- a/src/uu/hostid/Cargo.toml +++ b/src/uu/hostid/Cargo.toml @@ -16,7 +16,7 @@ path = "src/hostid.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/kill/Cargo.toml b/src/uu/kill/Cargo.toml index 354ad1d3f..24347a90a 100644 --- a/src/uu/kill/Cargo.toml +++ b/src/uu/kill/Cargo.toml @@ -16,7 +16,7 @@ path = "src/kill.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["signals"] } [[bin]] diff --git a/src/uu/logname/Cargo.toml b/src/uu/logname/Cargo.toml index 22b976dd6..fe7f2f738 100644 --- a/src/uu/logname/Cargo.toml +++ b/src/uu/logname/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" path = "src/logname.rs" [dependencies] -libc = "0.2.124" +libc = "0.2.125" clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/mkfifo/Cargo.toml b/src/uu/mkfifo/Cargo.toml index a6c801747..821d67d53 100644 --- a/src/uu/mkfifo/Cargo.toml +++ b/src/uu/mkfifo/Cargo.toml @@ -16,7 +16,7 @@ path = "src/mkfifo.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/mknod/Cargo.toml b/src/uu/mknod/Cargo.toml index 53cc62313..88c9e3fb0 100644 --- a/src/uu/mknod/Cargo.toml +++ b/src/uu/mknod/Cargo.toml @@ -17,7 +17,7 @@ path = "src/mknod.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "^0.2.124" +libc = "^0.2.125" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["mode"] } [[bin]] diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index 54283b9af..f999d6675 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -79,7 +79,11 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let template = matches.value_of(ARG_TEMPLATE).unwrap(); let tmpdir = matches.value_of(OPT_TMPDIR).unwrap_or_default(); - let (template, mut tmpdir) = if matches.is_present(OPT_TMPDIR) + // Treat the template string as a path to get the directory + // containing the last component. + let path = PathBuf::from(template); + + let (template, tmpdir) = if matches.is_present(OPT_TMPDIR) && !PathBuf::from(tmpdir).is_dir() // if a temp dir is provided, it must be an actual path && tmpdir.contains("XXX") // If this is a template, it has to contain at least 3 X @@ -97,8 +101,24 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let tmp = env::temp_dir(); (tmpdir, tmp) } else if !matches.is_present(OPT_TMPDIR) { - let tmp = env::temp_dir(); - (template, tmp) + // In this case, the command line was `mktemp -t XXX`, so we + // treat the argument `XXX` as though it were a filename + // regardless of whether it has path separators in it. + if matches.is_present(OPT_T) { + let tmp = env::temp_dir(); + (template, tmp) + // In this case, the command line was `mktemp XXX`, so we need + // to parse out the parent directory and the filename from the + // argument `XXX`, since it may be include path separators. + } else { + let tmp = match path.parent() { + None => PathBuf::from("."), + Some(d) => PathBuf::from(d), + }; + let filename = path.file_name(); + let template = filename.unwrap().to_str().unwrap(); + (template, tmp) + } } else { (template, PathBuf::from(tmpdir)) }; @@ -113,10 +133,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { return Err(MkTempError::InvalidTemplate(template.into()).into()); } - if matches.is_present(OPT_T) { - tmpdir = env::temp_dir(); - } - let res = if dry_run { dry_exec(tmpdir, prefix, rand, suffix) } else { @@ -272,5 +288,19 @@ fn exec(dir: &Path, prefix: &str, rand: usize, suffix: &str, make_dir: bool) -> .map_err(|e| MkTempError::PersistError(e.file.path().to_path_buf()))? .1 }; + + // Get just the last component of the path to the created + // temporary file or directory. + let filename = path.file_name(); + let filename = filename.unwrap().to_str().unwrap(); + + // Join the directory to the path to get the path to print. We + // cannot use the path returned by the `Builder` because it gives + // the absolute path and we need to return a filename that matches + // the template given on the command-line which might be a + // relative path. + let mut path = dir.to_path_buf(); + path.push(filename); + println_verbatim(path).map_err_context(|| "failed to print directory name".to_owned()) } diff --git a/src/uu/nice/Cargo.toml b/src/uu/nice/Cargo.toml index ab4b6c700..9b6ca52bd 100644 --- a/src/uu/nice/Cargo.toml +++ b/src/uu/nice/Cargo.toml @@ -16,7 +16,7 @@ path = "src/nice.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" nix = { version = "0.24.1", default-features = false } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } diff --git a/src/uu/nohup/Cargo.toml b/src/uu/nohup/Cargo.toml index 26e5fd7ae..ba38a7ecd 100644 --- a/src/uu/nohup/Cargo.toml +++ b/src/uu/nohup/Cargo.toml @@ -16,7 +16,7 @@ path = "src/nohup.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/nproc/Cargo.toml b/src/uu/nproc/Cargo.toml index 80c1cb38b..f52f2d0db 100644 --- a/src/uu/nproc/Cargo.toml +++ b/src/uu/nproc/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" path = "src/nproc.rs" [dependencies] -libc = "0.2.124" +libc = "0.2.125" num_cpus = "1.10" clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/pathchk/Cargo.toml b/src/uu/pathchk/Cargo.toml index 44cab8559..dd8b83076 100644 --- a/src/uu/pathchk/Cargo.toml +++ b/src/uu/pathchk/Cargo.toml @@ -16,7 +16,7 @@ path = "src/pathchk.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/ptx/src/ptx.rs b/src/uu/ptx/src/ptx.rs index 86a123530..2f253b580 100644 --- a/src/uu/ptx/src/ptx.rs +++ b/src/uu/ptx/src/ptx.rs @@ -5,7 +5,7 @@ // * For the full copyright and license information, please view the LICENSE // * file that was distributed with this source code. -// spell-checker:ignore (ToDOs) corasick memchr Roff trunc oset iset +// spell-checker:ignore (ToDOs) corasick memchr Roff trunc oset iset CHARCLASS use clap::{crate_version, Arg, Command}; use regex::Regex; @@ -31,6 +31,8 @@ const ABOUT: &str = "\ Mandatory arguments to long options are mandatory for short options too.\n\ With no FILE, or when FILE is -, read standard input. Default is '-F /'."; +const REGEX_CHARCLASS: &str = "^-]\\"; + #[derive(Debug)] enum OutFormat { Dumb, @@ -88,6 +90,18 @@ fn read_word_filter_file( Ok(words) } +/// reads contents of file as unique set of characters to be used with the break-file option +fn read_char_filter_file( + matches: &clap::ArgMatches, + option: &str, +) -> std::io::Result> { + let filename = matches.value_of(option).expect("parsing options failed!"); + let mut reader = File::open(filename)?; + let mut buffer = String::new(); + reader.read_to_string(&mut buffer)?; + Ok(buffer.chars().collect()) +} + #[derive(Debug)] struct WordFilter { only_specified: bool, @@ -113,9 +127,23 @@ impl WordFilter { } else { (false, HashSet::new()) }; - if matches.is_present(options::BREAK_FILE) { - return Err(PtxError::NotImplemented("-b").into()); - } + let break_set: Option> = if matches.is_present(options::BREAK_FILE) + && !matches.is_present(options::WORD_REGEXP) + { + let chars = + read_char_filter_file(matches, options::BREAK_FILE).map_err_context(String::new)?; + let mut hs: HashSet = if config.gnu_ext { + HashSet::new() // really only chars found in file + } else { + // GNU off means at least these are considered + [' ', '\t', '\n'].iter().cloned().collect() + }; + hs.extend(chars); + Some(hs) + } else { + // if -W takes precedence or default + None + }; // Ignore empty string regex from cmd-line-args let arg_reg: Option = if matches.is_present(options::WORD_REGEXP) { match matches.value_of(options::WORD_REGEXP) { @@ -134,7 +162,21 @@ impl WordFilter { let reg = match arg_reg { Some(arg_reg) => arg_reg, None => { - if config.gnu_ext { + if break_set.is_some() { + format!( + "[^{}]+", + break_set + .unwrap() + .into_iter() + .map(|c| if REGEX_CHARCLASS.contains(c) { + format!("\\{}", c) + } else { + c.to_string() + }) + .collect::>() + .join("") + ) + } else if config.gnu_ext { "\\w+".to_owned() } else { "[^ \t\n]+".to_owned() diff --git a/src/uu/rmdir/Cargo.toml b/src/uu/rmdir/Cargo.toml index b61def5ad..0894fa411 100644 --- a/src/uu/rmdir/Cargo.toml +++ b/src/uu/rmdir/Cargo.toml @@ -17,7 +17,7 @@ path = "src/rmdir.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } -libc = "0.2.124" +libc = "0.2.125" [[bin]] name = "rmdir" diff --git a/src/uu/sync/Cargo.toml b/src/uu/sync/Cargo.toml index ece7a5930..f6e57391d 100644 --- a/src/uu/sync/Cargo.toml +++ b/src/uu/sync/Cargo.toml @@ -16,7 +16,7 @@ path = "src/sync.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["wide"] } winapi = { version = "0.3", features = ["errhandlingapi", "fileapi", "handleapi", "std", "winbase", "winerror"] } diff --git a/src/uu/tail/Cargo.toml b/src/uu/tail/Cargo.toml index eebbf9606..7006ddb67 100644 --- a/src/uu/tail/Cargo.toml +++ b/src/uu/tail/Cargo.toml @@ -16,7 +16,7 @@ path = "src/tail.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["ringbuffer", "lines"] } [target.'cfg(windows)'.dependencies] diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index d018ee4a7..07ee9e33b 100644 --- a/src/uu/tee/Cargo.toml +++ b/src/uu/tee/Cargo.toml @@ -16,8 +16,8 @@ path = "src/tee.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" -retain_mut = "=0.1.2" # ToDO: [2021-01-01; rivy; maint/MinSRV] ~ v0.1.5 uses const generics which aren't stabilized until rust v1.51.0 +libc = "0.2.125" +retain_mut = "=0.1.7" # ToDO: [2021-01-01; rivy; maint/MinSRV] ~ v0.1.5 uses const generics which aren't stabilized until rust v1.51.0 uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["libc"] } [[bin]] diff --git a/src/uu/test/Cargo.toml b/src/uu/test/Cargo.toml index 6bd1cfc90..58f891541 100644 --- a/src/uu/test/Cargo.toml +++ b/src/uu/test/Cargo.toml @@ -16,7 +16,7 @@ path = "src/test.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" uucore = { version=">=0.0.11", package="uucore", path="../../uucore" } [target.'cfg(target_os = "redox")'.dependencies] diff --git a/src/uu/timeout/Cargo.toml b/src/uu/timeout/Cargo.toml index e555cb1b7..d285c3214 100644 --- a/src/uu/timeout/Cargo.toml +++ b/src/uu/timeout/Cargo.toml @@ -16,7 +16,7 @@ path = "src/timeout.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" nix = { version = "0.24.1", default-features = false, features = ["signal"] } uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["process", "signals"] } diff --git a/src/uu/tty/Cargo.toml b/src/uu/tty/Cargo.toml index 2f3438558..da6446ab0 100644 --- a/src/uu/tty/Cargo.toml +++ b/src/uu/tty/Cargo.toml @@ -16,7 +16,7 @@ path = "src/tty.rs" [dependencies] clap = { version = "3.1", features = ["wrap_help", "cargo"] } -libc = "0.2.124" +libc = "0.2.125" atty = "0.2" uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["fs"] } diff --git a/src/uu/whoami/Cargo.toml b/src/uu/whoami/Cargo.toml index 2655fe892..253e2ba1b 100644 --- a/src/uu/whoami/Cargo.toml +++ b/src/uu/whoami/Cargo.toml @@ -22,7 +22,7 @@ uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=[ winapi = { version = "0.3", features = ["lmcons"] } [target.'cfg(unix)'.dependencies] -libc = "0.2.124" +libc = "0.2.125" [[bin]] name = "whoami" diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index c86a8cf07..7a350146e 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -31,7 +31,7 @@ time = { version="<= 0.3", optional=true, features = ["formatting", "local-offse data-encoding = { version="2.1", optional=true } data-encoding-macro = { version="0.1.12", optional=true } z85 = { version="3.0.5", optional=true } -libc = { version="0.2.124", optional=true } +libc = { version="0.2.125", optional=true } once_cell = "1.10.0" os_display = "0.1.3" diff --git a/src/uucore/src/lib/features/tokenize/sub.rs b/src/uucore/src/lib/features/tokenize/sub.rs index f8b5b5caf..216953a43 100644 --- a/src/uucore/src/lib/features/tokenize/sub.rs +++ b/src/uucore/src/lib/features/tokenize/sub.rs @@ -152,7 +152,11 @@ impl SubParser { if parser.min_width_is_asterisk { CanAsterisk::Asterisk } else { - CanAsterisk::Fixed(parser.min_width_tmp.map(|x| x.parse::().unwrap())) + CanAsterisk::Fixed( + parser + .min_width_tmp + .map(|x| x.parse::().unwrap_or(1)), + ) }, if parser.second_field_is_asterisk { CanAsterisk::Asterisk diff --git a/tests/by-util/test_dir.rs b/tests/by-util/test_dir.rs index 3ec416bb2..8c586a628 100644 --- a/tests/by-util/test_dir.rs +++ b/tests/by-util/test_dir.rs @@ -31,7 +31,7 @@ fn test_default_output() { scene .ucmd() .succeeds() - .stdout_does_not_match(&Regex::new("[rwx][^some-file1]").unwrap()); + .stdout_does_not_match(&Regex::new("[rwx-]{10}.*some-file1$").unwrap()); } #[test] @@ -51,5 +51,5 @@ fn test_long_output() { .ucmd() .arg("-l") .succeeds() - .stdout_matches(&Regex::new("[rwx][^some-file1]").unwrap()); + .stdout_matches(&Regex::new("[rwx-]{10}.*some-file1$").unwrap()); } diff --git a/tests/by-util/test_mktemp.rs b/tests/by-util/test_mktemp.rs index e824df061..c28efc37b 100644 --- a/tests/by-util/test_mktemp.rs +++ b/tests/by-util/test_mktemp.rs @@ -411,3 +411,74 @@ fn test_mktemp_directory_tmpdir() { result.no_stderr().stdout_contains("apt-key-gpghome."); assert!(PathBuf::from(result.stdout_str().trim()).is_dir()); } + +/// Decide whether a string matches a given template. +/// +/// In the template, the character `'X'` is treated as a wildcard, +/// that is, it matches anything. All other characters in `template` +/// and `s` must match exactly. +/// +/// # Examples +/// +/// ```rust,ignore +/// # These all match. +/// assert!(matches_template("abc", "abc")); +/// assert!(matches_template("aXc", "abc")); +/// assert!(matches_template("XXX", "abc")); +/// +/// # None of these match +/// assert!(matches_template("abc", "abcd")); +/// assert!(matches_template("abc", "ab")); +/// assert!(matches_template("aXc", "abd")); +/// assert!(matches_template("XXX", "abcd")); +/// ``` +/// +fn matches_template(template: &str, s: &str) -> bool { + if template.len() != s.len() { + return false; + } + for (a, b) in template.chars().zip(s.chars()) { + if !(a == 'X' || a == b) { + return false; + } + } + true +} + +/// An assertion that uses [`matches_template`] and adds a helpful error message. +macro_rules! assert_matches_template { + ($template:expr, $s:expr) => {{ + assert!( + matches_template($template, $s), + "\"{}\" != \"{}\"", + $template, + $s + ); + }}; +} + +/// Test that the file is created in the directory given by the template. +#[test] +fn test_respect_template() { + let (at, mut ucmd) = at_and_ucmd!(); + let template = "XXX"; + let result = ucmd.arg(template).succeeds(); + let filename = result.no_stderr().stdout_str().trim_end(); + assert_matches_template!(template, filename); + assert!(at.file_exists(filename)); +} + +/// Test that the file is created in the directory given by the template. +#[test] +fn test_respect_template_directory() { + let (at, mut ucmd) = at_and_ucmd!(); + at.mkdir("d"); + #[cfg(not(windows))] + let template = "d/XXX"; + #[cfg(windows)] + let template = r"d\XXX"; + let result = ucmd.arg(template).succeeds(); + let filename = result.no_stderr().stdout_str().trim_end(); + assert_matches_template!(template, filename); + assert!(at.file_exists(filename)); +} diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index d5be4cd17..77f64750c 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -446,6 +446,14 @@ fn sub_any_specifiers_after_period() { .stdout_only("3"); } +#[test] +fn unspecified_left_justify_is_1_width() { + new_ucmd!() + .args(&["%-o"]) //spell-checker:disable-line + .succeeds() + .stdout_only("0"); +} + #[test] fn sub_any_specifiers_after_second_param() { new_ucmd!() diff --git a/tests/by-util/test_ptx.rs b/tests/by-util/test_ptx.rs index c17d473f5..75c96e42e 100644 --- a/tests/by-util/test_ptx.rs +++ b/tests/by-util/test_ptx.rs @@ -71,3 +71,35 @@ fn gnu_ext_disabled_ignore_and_only_file() { .succeeds() .stdout_only_fixture("gnu_ext_disabled_ignore_and_only_file.expected"); } + +#[test] +fn gnu_ext_disabled_output_width_50() { + new_ucmd!() + .args(&["-G", "-w", "50", "input"]) + .succeeds() + .stdout_only_fixture("gnu_ext_disabled_output_width_50.expected"); +} + +#[test] +fn gnu_ext_disabled_output_width_70() { + new_ucmd!() + .args(&["-G", "-w", "70", "input"]) + .succeeds() + .stdout_only_fixture("gnu_ext_disabled_output_width_70.expected"); +} + +#[test] +fn gnu_ext_disabled_break_file() { + new_ucmd!() + .args(&["-G", "-b", "break_file", "input"]) + .succeeds() + .stdout_only_fixture("gnu_ext_disabled_break_file.expected"); +} + +#[test] +fn gnu_ext_disabled_empty_word_regexp_ignores_break_file() { + new_ucmd!() + .args(&["-G", "-b", "break_file", "-R", "-W", "", "input"]) + .succeeds() + .stdout_only_fixture("gnu_ext_disabled_rightward_no_ref.expected"); +} diff --git a/tests/by-util/test_vdir.rs b/tests/by-util/test_vdir.rs index 01c540095..41bce1c40 100644 --- a/tests/by-util/test_vdir.rs +++ b/tests/by-util/test_vdir.rs @@ -31,7 +31,7 @@ fn test_default_output() { scene .ucmd() .succeeds() - .stdout_matches(&Regex::new("[rwx][^some-file1]").unwrap()); + .stdout_matches(&Regex::new("[rwx-]{10}.*some-file1$").unwrap()); } #[test] @@ -51,5 +51,5 @@ fn test_column_output() { .ucmd() .arg("-C") .succeeds() - .stdout_does_not_match(&Regex::new("[rwx][^some-file1]").unwrap()); + .stdout_does_not_match(&Regex::new("[rwx-]{10}.*some-file1$").unwrap()); } diff --git a/tests/fixtures/ptx/break_file b/tests/fixtures/ptx/break_file new file mode 100644 index 000000000..499598c20 --- /dev/null +++ b/tests/fixtures/ptx/break_file @@ -0,0 +1 @@ +abc_e^-]\ diff --git a/tests/fixtures/ptx/gnu_ext_disabled_break_file.expected b/tests/fixtures/ptx/gnu_ext_disabled_break_file.expected new file mode 100644 index 000000000..7ea13471d --- /dev/null +++ b/tests/fixtures/ptx/gnu_ext_disabled_break_file.expected @@ -0,0 +1,42 @@ +.xx "" "" """quotes"", for roff" "" +.xx "" "and some other like %a, b" "#, c$c" "" +.xx "" "and some other like %a, b#, c" "$c" "" +.xx "" "and some other like" "%a, b#, c$c" "" +.xx "" "and some other like %a" ", b#, c$c" "" +.xx "" """quotes""," "for roff" "" +.xx "" "{brackets}" "for tex" "" +.xx "" "" "hello world!" "" +.xx "" "let's c" "heck special characters:" "" +.xx "" "let's check special c" "haracters:" "" +.xx "" "let's check spec" "ial characters:" "" +.xx "" "let's chec" "k special characters:" "" +.xx "" "{brac" "kets} for tex" "" +.xx "" "oh, and bac" "k\slash" "" +.xx "" "" "let's check special characters:" "" +.xx "" "let's check specia" "l characters:" "" +.xx "" "and some other" "like %a, b#, c$c" "" +.xx "" "he" "llo world!" "" +.xx "" "maybe a" "lso~or^" "" +.xx "" "" "maybe also~or^" "" +.xx "" "a" "nd some other like %a, b#, c$c" "" +.xx "" "oh, a" "nd back\slash" "" +.xx "" "" "oh, and back\slash" "" +.xx "" "and some" "other like %a, b#, c$c" "" +.xx "" "let's check special cha" "racters:" "" +.xx "" "{b" "rackets} for tex" "" +.xx "" "and some othe" "r like %a, b#, c$c" "" +.xx "" """quotes"", for" "roff" "" +.xx "" "let's check special characte" "rs:" "" +.xx "" """quote" "s"", for roff" "" +.xx "" "oh, and back\sla" "sh" "" +.xx "" "oh, and back\" "slash" "" +.xx "" "and" "some other like %a, b#, c$c" "" +.xx "" "let's check" "special characters:" "" +.xx "" "let's check special charac" "ters:" "" +.xx "" "{brackets} for" "tex" "" +.xx "" "le" "t's check special characters:" "" +.xx "" "{bracke" "ts} for tex" "" +.xx "" "hello" "world!" "" +.xx "" "{brackets} for te" "x" "" +.xx "" "ma" "ybe also~or^" "" +.xx "" "" "{brackets} for tex" "" diff --git a/tests/fixtures/ptx/gnu_ext_disabled_output_width_50.expected b/tests/fixtures/ptx/gnu_ext_disabled_output_width_50.expected new file mode 100644 index 000000000..c71b0508c --- /dev/null +++ b/tests/fixtures/ptx/gnu_ext_disabled_output_width_50.expected @@ -0,0 +1,24 @@ +.xx "" "" """quotes"", for roff" "" +.xx "" "and some other like" "%a, b#, c$c" "" +.xx "" "maybe" "also~or^" "" +.xx "%a, b#, c$c" "" "and some other like" "" +.xx "" "oh," "and back\slash" "" +.xx "" "some other like %a," "b#, c$c" "and" +.xx "" "oh, and" "back\slash" "" +.xx "" "other like %a, b#," "c$c" "and some" +.xx "" "let's check special" "characters:" "" +.xx "characters:" "let's" "check special" "" +.xx "" """quotes""," "for roff" "" +.xx "" "{brackets}" "for tex" "" +.xx "" "" "hello world!" "" +.xx "characters:" "" "let's check special" "" +.xx "" "and some other" "like %a, b#, c$c" "" +.xx "" "" "maybe also~or^" "" +.xx "" "" "oh, and back\slash" "" +.xx "" "and some" "other like %a, b#, c$c" "" +.xx "" """quotes"", for" "roff" "" +.xx "b#, c$c" "and" "some other like %a," "" +.xx "" "let's check" "special characters:" "" +.xx "" "{brackets} for" "tex" "" +.xx "" "hello" "world!" "" +.xx "" "" "{brackets} for tex" "" diff --git a/tests/fixtures/ptx/gnu_ext_disabled_output_width_70.expected b/tests/fixtures/ptx/gnu_ext_disabled_output_width_70.expected new file mode 100644 index 000000000..3886e087d --- /dev/null +++ b/tests/fixtures/ptx/gnu_ext_disabled_output_width_70.expected @@ -0,0 +1,24 @@ +.xx "" "" """quotes"", for roff" "" +.xx "" "and some other like" "%a, b#, c$c" "" +.xx "" "maybe" "also~or^" "" +.xx "" "" "and some other like %a, b#, c$c" "" +.xx "" "oh," "and back\slash" "" +.xx "" "and some other like %a," "b#, c$c" "" +.xx "" "oh, and" "back\slash" "" +.xx "" "and some other like %a, b#," "c$c" "" +.xx "" "let's check special" "characters:" "" +.xx "" "let's" "check special characters:" "" +.xx "" """quotes""," "for roff" "" +.xx "" "{brackets}" "for tex" "" +.xx "" "" "hello world!" "" +.xx "" "" "let's check special characters:" "" +.xx "" "and some other" "like %a, b#, c$c" "" +.xx "" "" "maybe also~or^" "" +.xx "" "" "oh, and back\slash" "" +.xx "" "and some" "other like %a, b#, c$c" "" +.xx "" """quotes"", for" "roff" "" +.xx "" "and" "some other like %a, b#, c$c" "" +.xx "" "let's check" "special characters:" "" +.xx "" "{brackets} for" "tex" "" +.xx "" "hello" "world!" "" +.xx "" "" "{brackets} for tex" "" diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 6f0ec32f7..83993fde9 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -62,14 +62,23 @@ for binary in $(./build-aux/gen-lists-of-programs.sh --list-progs); do } done -./bootstrap -./configure --quiet --disable-gcc-warnings -#Add timeout to to protect against hangs -sed -i 's|^"\$@|/usr/bin/timeout 600 "\$@|' build-aux/test-driver -# Change the PATH in the Makefile to test the uutils coreutils instead of the GNU coreutils -sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${UU_BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile -sed -i 's| tr | /usr/bin/tr |' tests/init.sh -make -j "$(nproc)" +if test -f gnu-built; then + echo "GNU build already found. Skip" + echo "'rm -f $(pwd)/gnu-built' to force the build" + echo "Note: the customization of the tests will still happen" + exit 0 +else + ./bootstrap + ./configure --quiet --disable-gcc-warnings + #Add timeout to to protect against hangs + sed -i 's|^"\$@|/usr/bin/timeout 600 "\$@|' build-aux/test-driver + # Change the PATH in the Makefile to test the uutils coreutils instead of the GNU coreutils + sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${UU_BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile + sed -i 's| tr | /usr/bin/tr |' tests/init.sh + make -j "$(nproc)" + touch gnu-built +fi + # Handle generated factor tests t_first=00 t_max=36