1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Fix stdbuf regression.

When replacing range_inclusive(), I introduced a bug when parsing
arguments. I added a smoke test to prevent basic regressions in the
future.
This commit is contained in:
Joseph Crail 2015-07-09 15:02:38 -04:00
parent 6b927c2ec3
commit b8ab2c125f
3 changed files with 18 additions and 1 deletions

View file

@ -185,6 +185,7 @@ TEST_PROGS := \
seq \
sort \
split \
stdbuf \
tac \
test \
tr \

View file

@ -225,7 +225,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
let mut options = ProgramOptions {stdin: BufferType::Default, stdout: BufferType::Default, stderr: BufferType::Default};
let mut command_idx = -1;
for i in 1 .. args.len()-1 {
for i in 1 .. args.len()+1 {
match parse_options(&args[1 .. i], &mut options, &opts) {
Ok(OkMsg::Buffering) => {
command_idx = i - 1;

16
test/stdbuf.rs Normal file
View file

@ -0,0 +1,16 @@
use std::process::Command;
use util::*;
static PROGNAME: &'static str = "./stdbuf";
#[path = "common/util.rs"]
#[macro_use]
mod util;
#[test]
fn test_stdbuf_unbuffered_stdout() {
// This is a basic smoke test
let mut cmd = Command::new(PROGNAME);
let result = run_piped_stdin(&mut cmd.args(&["-o0", "head"]), "The quick brown fox jumps over the lazy dog.");
assert_eq!(result.stdout, "The quick brown fox jumps over the lazy dog.");
}