From fd2536fc578c07a91bd724a74ababf4aeed2e3cb Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 10 Jan 2015 19:54:42 +0100 Subject: [PATCH] mv, sort, truncate: fix test build --- test/mv.rs | 14 ++++---------- test/sort.rs | 4 ++-- test/truncate.rs | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/test/mv.rs b/test/mv.rs index b5d5916a8..2302afbca 100644 --- a/test/mv.rs +++ b/test/mv.rs @@ -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); diff --git a/test/sort.rs b/test/sort.rs index 292a63e44..eeaf65f0f 100644 --- a/test/sort.rs +++ b/test/sort.rs @@ -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()); } diff --git a/test/truncate.rs b/test/truncate.rs index 2bdcea8a0..067716fd2 100644 --- a/test/truncate.rs +++ b/test/truncate.rs @@ -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();