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

mv, sort, truncate: fix test build

This commit is contained in:
Michael Gehring 2015-01-10 19:54:42 +01:00
parent 1604c361b9
commit fd2536fc57
3 changed files with 7 additions and 13 deletions

View file

@ -30,11 +30,11 @@ fn run(cmd: &mut Command) -> CmdResult {
stdout: from_utf8(prog.output.as_slice()).unwrap().to_owned(),
}
}
fn run_interactive(cmd: &mut Command, f: |&mut PipeStream|) -> CmdResult {
fn run_interactive(cmd: &mut Command, input: &[u8])-> CmdResult {
let stdin_cfg = process::CreatePipe(true, false);
let mut command = cmd.stdin(stdin_cfg).spawn().unwrap();
f(command.stdin.as_mut().unwrap());
command.stdin.as_mut().unwrap().write(input);
let prog = command.wait_with_output().unwrap();
CmdResult {
@ -140,10 +140,7 @@ fn test_mv_interactive() {
touch(file_b);
let ia1 = |stdin: &mut PipeStream| {
stdin.write(b"n").unwrap();
};
let result1 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), ia1);
let result1 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), b"n");
assert_empty_stderr!(result1);
assert!(result1.success);
@ -152,10 +149,7 @@ fn test_mv_interactive() {
assert!(Path::new(file_b).is_file());
let ia2 = |stdin: &mut PipeStream| {
stdin.write(b"Yesh").unwrap();
};
let result2 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), ia2);
let result2 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), b"Yesh");
assert_empty_stderr!(result2);
assert!(result2.success);

View file

@ -29,7 +29,7 @@ fn numeric5() {
numeric_helper(5);
}
fn numeric_helper(test_num: int) {
fn numeric_helper(test_num: isize) {
let mut cmd = Command::new(PROGNAME);
cmd.arg("-n");
let po = match cmd.clone().arg(format!("{}{}{}", "numeric", test_num, ".txt")).output() {
@ -42,5 +42,5 @@ fn numeric_helper(test_num: int) {
Ok(answer) => answer,
Err(err) => panic!("{}", err),
};
assert_eq!(String::from_utf8(po.output), String::from_utf8(answer));
assert_eq!(String::from_utf8(po.output).unwrap(), String::from_utf8(answer).unwrap());
}

View file

@ -34,7 +34,7 @@ fn test_decrease_file_size() {
}
file.seek(0, io::SeekEnd).unwrap();
if file.tell().unwrap() != 6 {
println!("{}", file.tell());
println!("{:?}", file.tell());
panic!();
}
io::fs::unlink(&Path::new(TFILE2)).unwrap();