mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-01 13:37:48 +00:00
mv, sort, truncate: fix test build
This commit is contained in:
parent
1604c361b9
commit
fd2536fc57
3 changed files with 7 additions and 13 deletions
14
test/mv.rs
14
test/mv.rs
|
@ -30,11 +30,11 @@ fn run(cmd: &mut Command) -> CmdResult {
|
||||||
stdout: from_utf8(prog.output.as_slice()).unwrap().to_owned(),
|
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 stdin_cfg = process::CreatePipe(true, false);
|
||||||
let mut command = cmd.stdin(stdin_cfg).spawn().unwrap();
|
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();
|
let prog = command.wait_with_output().unwrap();
|
||||||
CmdResult {
|
CmdResult {
|
||||||
|
@ -140,10 +140,7 @@ fn test_mv_interactive() {
|
||||||
touch(file_b);
|
touch(file_b);
|
||||||
|
|
||||||
|
|
||||||
let ia1 = |stdin: &mut PipeStream| {
|
let result1 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), b"n");
|
||||||
stdin.write(b"n").unwrap();
|
|
||||||
};
|
|
||||||
let result1 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), ia1);
|
|
||||||
|
|
||||||
assert_empty_stderr!(result1);
|
assert_empty_stderr!(result1);
|
||||||
assert!(result1.success);
|
assert!(result1.success);
|
||||||
|
@ -152,10 +149,7 @@ fn test_mv_interactive() {
|
||||||
assert!(Path::new(file_b).is_file());
|
assert!(Path::new(file_b).is_file());
|
||||||
|
|
||||||
|
|
||||||
let ia2 = |stdin: &mut PipeStream| {
|
let result2 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), b"Yesh");
|
||||||
stdin.write(b"Yesh").unwrap();
|
|
||||||
};
|
|
||||||
let result2 = run_interactive(Command::new(EXE).arg("-i").arg(file_a).arg(file_b), ia2);
|
|
||||||
|
|
||||||
assert_empty_stderr!(result2);
|
assert_empty_stderr!(result2);
|
||||||
assert!(result2.success);
|
assert!(result2.success);
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn numeric5() {
|
||||||
numeric_helper(5);
|
numeric_helper(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn numeric_helper(test_num: int) {
|
fn numeric_helper(test_num: isize) {
|
||||||
let mut cmd = Command::new(PROGNAME);
|
let mut cmd = Command::new(PROGNAME);
|
||||||
cmd.arg("-n");
|
cmd.arg("-n");
|
||||||
let po = match cmd.clone().arg(format!("{}{}{}", "numeric", test_num, ".txt")).output() {
|
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,
|
Ok(answer) => answer,
|
||||||
Err(err) => panic!("{}", err),
|
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());
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ fn test_decrease_file_size() {
|
||||||
}
|
}
|
||||||
file.seek(0, io::SeekEnd).unwrap();
|
file.seek(0, io::SeekEnd).unwrap();
|
||||||
if file.tell().unwrap() != 6 {
|
if file.tell().unwrap() != 6 {
|
||||||
println!("{}", file.tell());
|
println!("{:?}", file.tell());
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
io::fs::unlink(&Path::new(TFILE2)).unwrap();
|
io::fs::unlink(&Path::new(TFILE2)).unwrap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue