mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Fix for latest Rust
This commit is contained in:
parent
0d8cfbbe45
commit
8cf617d08f
6 changed files with 30 additions and 29 deletions
23
cat/test.rs
23
cat/test.rs
|
@ -1,10 +1,11 @@
|
|||
use std::{run, str};
|
||||
use std::io::process::{Process, ProcessConfig};
|
||||
use std::str;
|
||||
|
||||
#[test]
|
||||
fn test_output_multi_files_print_all_chars() {
|
||||
let prog = run::process_output("build/cat",
|
||||
[~"cat/fixtures/alpha.txt", ~"cat/fixtures/256.txt",
|
||||
~"-A", ~"-n"]).unwrap();
|
||||
let prog = Process::output("build/cat",
|
||||
[~"cat/fixtures/alpha.txt", ~"cat/fixtures/256.txt",
|
||||
~"-A", ~"-n"]).unwrap();
|
||||
let out = str::from_utf8_owned(prog.output).unwrap();
|
||||
assert_eq!(out,
|
||||
~" 1\tabcde$\n 2\tfghij$\n 3\tklmno$\n 4\tpqrst$\n 5\tuvwxyz$\n 6\t^@^A^B^C^D^E^F^G^H^I$\n 7\t^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_ !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?M-^@M-^AM-^BM-^CM-^DM-^EM-^FM-^GM-^HM-^IM-^JM-^KM-^LM-^MM-^NM-^OM-^PM-^QM-^RM-^SM-^TM-^UM-^VM-^WM-^XM-^YM-^ZM-^[M-^\\M-^]M-^^M-^_M- M-!M-\"M-#M-$M-%M-&M-\'M-(M-)M-*M-+M-,M--M-.M-/M-0M-1M-2M-3M-4M-5M-6M-7M-8M-9M-:M-;M-<M-=M->M-?M-@M-AM-BM-CM-DM-EM-FM-GM-HM-IM-JM-KM-LM-MM-NM-OM-PM-QM-RM-SM-TM-UM-VM-WM-XM-YM-ZM-[M-\\M-]M-^M-_M-`M-aM-bM-cM-dM-eM-fM-gM-hM-iM-jM-kM-lM-mM-nM-oM-pM-qM-rM-sM-tM-uM-vM-wM-xM-yM-zM-{M-|M-}M-~M-^?");
|
||||
|
@ -12,22 +13,20 @@ fn test_output_multi_files_print_all_chars() {
|
|||
|
||||
#[test]
|
||||
fn test_stdin_squeeze() {
|
||||
let mut prog = run::Process::new("build/cat", [~"-A"], run::ProcessOptions::new()).unwrap();
|
||||
let mut prog = Process::new("build/cat", [~"-A"]).unwrap();
|
||||
|
||||
prog.input().write(bytes!("\x00\x01\x02"));
|
||||
prog.close_input();
|
||||
prog.stdin.take_unwrap().write(bytes!("\x00\x01\x02"));
|
||||
|
||||
let out = str::from_utf8_owned(prog.finish_with_output().output).unwrap();
|
||||
let out = str::from_utf8_owned(prog.wait_with_output().output).unwrap();
|
||||
assert_eq!(out, ~"^@^A^B");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_stdin_number_non_blank() {
|
||||
let mut prog = run::Process::new("build/cat", [~"-b", ~"-"], run::ProcessOptions::new()).unwrap();
|
||||
let mut prog = Process::new("build/cat", [~"-b", ~"-"]).unwrap();
|
||||
|
||||
prog.input().write(bytes!("\na\nb\n\n\nc"));
|
||||
prog.close_input();
|
||||
prog.stdin.take_unwrap().write(bytes!("\na\nb\n\n\nc"));
|
||||
|
||||
let out = str::from_utf8_owned(prog.finish_with_output().output).unwrap();
|
||||
let out = str::from_utf8_owned(prog.wait_with_output().output).unwrap();
|
||||
assert_eq!(out, ~"\n 1\ta\n 2\tb\n\n\n 3\tc");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#[allow(dead_code)];
|
||||
#[allow(dead_code, non_camel_case_types)];
|
||||
|
||||
extern crate getopts;
|
||||
|
||||
|
|
2
env/env.rs
vendored
2
env/env.rs
vendored
|
@ -191,7 +191,7 @@ fn main() {
|
|||
}
|
||||
|
||||
if opts.program.len() >= 1 {
|
||||
match std::run::process_status(opts.program[0].as_slice(), opts.program.slice_from(1)) {
|
||||
match std::io::process::Process::status(opts.program[0].as_slice(), opts.program.slice_from(1)) {
|
||||
Ok(exit) =>
|
||||
std::os::set_exit_status(match exit {
|
||||
std::io::process::ExitStatus(s) => s,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{run};
|
||||
use std::io::process::Process;
|
||||
use std::io::fs::rmdir;
|
||||
|
||||
static exe: &'static str = "build/mkdir";
|
||||
|
@ -19,7 +19,7 @@ fn cleanup(dir: &'static str) {
|
|||
#[test]
|
||||
fn test_mkdir_mkdir() {
|
||||
cleanup(test_dir1);
|
||||
let prog = run::process_status(exe.into_owned(), [test_dir1.into_owned()]);
|
||||
let prog = Process::status(exe.into_owned(), [test_dir1.into_owned()]);
|
||||
let exit_success = prog.unwrap().success();
|
||||
cleanup(test_dir1);
|
||||
assert_eq!(exit_success, true);
|
||||
|
@ -28,13 +28,13 @@ fn test_mkdir_mkdir() {
|
|||
#[test]
|
||||
fn test_mkdir_dup_dir() {
|
||||
cleanup(test_dir2);
|
||||
let prog = run::process_status(exe.into_owned(), [test_dir2.into_owned()]);
|
||||
let prog = Process::status(exe.into_owned(), [test_dir2.into_owned()]);
|
||||
let exit_success = prog.unwrap().success();
|
||||
if !exit_success {
|
||||
cleanup(test_dir2);
|
||||
fail!();
|
||||
}
|
||||
let prog2 = run::process_status(exe.into_owned(), [test_dir2.into_owned()]);
|
||||
let prog2 = Process::status(exe.into_owned(), [test_dir2.into_owned()]);
|
||||
let exit_success2 = prog2.unwrap().success();
|
||||
cleanup(test_dir2);
|
||||
assert_eq!(exit_success2, false);
|
||||
|
@ -43,7 +43,7 @@ fn test_mkdir_dup_dir() {
|
|||
#[test]
|
||||
fn test_mkdir_mode() {
|
||||
cleanup(test_dir3);
|
||||
let prog = run::process_status(exe.into_owned(), [~"-m", ~"755", test_dir3.into_owned()]);
|
||||
let prog = Process::status(exe.into_owned(), [~"-m", ~"755", test_dir3.into_owned()]);
|
||||
let exit_success = prog.unwrap().success();
|
||||
cleanup(test_dir3);
|
||||
assert_eq!(exit_success, true);
|
||||
|
@ -52,7 +52,7 @@ fn test_mkdir_mode() {
|
|||
#[test]
|
||||
fn test_mkdir_parent() {
|
||||
cleanup(test_dir4);
|
||||
let prog = run::process_status(exe.into_owned(), [~"-p", test_dir4.into_owned()]);
|
||||
let prog = Process::status(exe.into_owned(), [~"-p", test_dir4.into_owned()]);
|
||||
let exit_success = prog.unwrap().success();
|
||||
cleanup(test_dir4);
|
||||
assert_eq!(exit_success, true);
|
||||
|
@ -61,7 +61,7 @@ fn test_mkdir_parent() {
|
|||
#[test]
|
||||
fn test_mkdir_no_parent() {
|
||||
cleanup(test_dir5);
|
||||
let prog = run::process_status(exe.into_owned(), [test_dir5.into_owned()]);
|
||||
let prog = Process::status(exe.into_owned(), [test_dir5.into_owned()]);
|
||||
let exit_success = prog.unwrap().success();
|
||||
cleanup(test_dir5);
|
||||
assert_eq!(exit_success, false);
|
||||
|
|
11
seq/test.rs
11
seq/test.rs
|
@ -1,29 +1,30 @@
|
|||
use std::{run,str};
|
||||
use std::io::process::Process;
|
||||
use std::str;
|
||||
|
||||
#[test]
|
||||
fn test_count_up() {
|
||||
let p = run::process_output("build/seq", [~"10"]).unwrap();
|
||||
let p = Process::output("build/seq", [~"10"]).unwrap();
|
||||
let out = str::from_utf8(p.output).unwrap().into_owned();
|
||||
assert_eq!(out, ~"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_count_down() {
|
||||
let p = run::process_output("build/seq", [~"--", ~"5", ~"-1", ~"1"]).unwrap();
|
||||
let p = Process::output("build/seq", [~"--", ~"5", ~"-1", ~"1"]).unwrap();
|
||||
let out = str::from_utf8(p.output).unwrap().into_owned();
|
||||
assert_eq!(out, ~"5\n4\n3\n2\n1\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_separator_and_terminator() {
|
||||
let p = run::process_output("build/seq", [~"-s", ~",", ~"-t", ~"!", ~"2", ~"6"]).unwrap();
|
||||
let p = Process::output("build/seq", [~"-s", ~",", ~"-t", ~"!", ~"2", ~"6"]).unwrap();
|
||||
let out = str::from_utf8(p.output).unwrap().into_owned();
|
||||
assert_eq!(out, ~"2,3,4,5,6!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_equalize_widths() {
|
||||
let p = run::process_output("build/seq", [~"-w", ~"5", ~"10"]).unwrap();
|
||||
let p = Process::output("build/seq", [~"-w", ~"5", ~"10"]).unwrap();
|
||||
let out = str::from_utf8(p.output).unwrap().into_owned();
|
||||
assert_eq!(out, ~"05\n06\n07\n08\n09\n10\n");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use std::{run, io};
|
||||
use std::io;
|
||||
use std::io::process::Process;
|
||||
|
||||
static PROG: &'static str = "build/truncate";
|
||||
static TFILE1: &'static str = "truncate_test_1";
|
||||
|
@ -14,7 +15,7 @@ fn make_file(name: &str) -> io::File {
|
|||
#[test]
|
||||
fn test_increase_file_size() {
|
||||
let mut file = make_file(TFILE1);
|
||||
if !run::process_status(PROG, [~"-s", ~"+5K", TFILE1.to_owned()]).unwrap().success() {
|
||||
if !Process::status(PROG, [~"-s", ~"+5K", TFILE1.to_owned()]).unwrap().success() {
|
||||
fail!();
|
||||
}
|
||||
file.seek(0, io::SeekEnd);
|
||||
|
@ -28,7 +29,7 @@ fn test_increase_file_size() {
|
|||
fn test_decrease_file_size() {
|
||||
let mut file = make_file(TFILE2);
|
||||
file.write(bytes!("1234567890"));
|
||||
if !run::process_status(PROG, [~"--size=-4", TFILE2.to_owned()]).unwrap().success() {
|
||||
if !Process::status(PROG, [~"--size=-4", TFILE2.to_owned()]).unwrap().success() {
|
||||
fail!();
|
||||
}
|
||||
file.seek(0, io::SeekEnd);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue