1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Fix for latest Rust

This commit is contained in:
Arcterus 2014-02-26 19:35:50 -08:00
parent 0d8cfbbe45
commit 8cf617d08f
6 changed files with 30 additions and 29 deletions

View file

@ -1,8 +1,9 @@
use std::{run, str}; use std::io::process::{Process, ProcessConfig};
use std::str;
#[test] #[test]
fn test_output_multi_files_print_all_chars() { fn test_output_multi_files_print_all_chars() {
let prog = run::process_output("build/cat", let prog = Process::output("build/cat",
[~"cat/fixtures/alpha.txt", ~"cat/fixtures/256.txt", [~"cat/fixtures/alpha.txt", ~"cat/fixtures/256.txt",
~"-A", ~"-n"]).unwrap(); ~"-A", ~"-n"]).unwrap();
let out = str::from_utf8_owned(prog.output).unwrap(); let out = str::from_utf8_owned(prog.output).unwrap();
@ -12,22 +13,20 @@ fn test_output_multi_files_print_all_chars() {
#[test] #[test]
fn test_stdin_squeeze() { 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.stdin.take_unwrap().write(bytes!("\x00\x01\x02"));
prog.close_input();
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"); assert_eq!(out, ~"^@^A^B");
} }
#[test] #[test]
fn test_stdin_number_non_blank() { 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.stdin.take_unwrap().write(bytes!("\na\nb\n\n\nc"));
prog.close_input();
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"); assert_eq!(out, ~"\n 1\ta\n 2\tb\n\n\n 3\tc");
} }

View file

@ -1,4 +1,4 @@
#[allow(dead_code)]; #[allow(dead_code, non_camel_case_types)];
extern crate getopts; extern crate getopts;

2
env/env.rs vendored
View file

@ -191,7 +191,7 @@ fn main() {
} }
if opts.program.len() >= 1 { 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) => Ok(exit) =>
std::os::set_exit_status(match exit { std::os::set_exit_status(match exit {
std::io::process::ExitStatus(s) => s, std::io::process::ExitStatus(s) => s,

View file

@ -1,4 +1,4 @@
use std::{run}; use std::io::process::Process;
use std::io::fs::rmdir; use std::io::fs::rmdir;
static exe: &'static str = "build/mkdir"; static exe: &'static str = "build/mkdir";
@ -19,7 +19,7 @@ fn cleanup(dir: &'static str) {
#[test] #[test]
fn test_mkdir_mkdir() { fn test_mkdir_mkdir() {
cleanup(test_dir1); 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(); let exit_success = prog.unwrap().success();
cleanup(test_dir1); cleanup(test_dir1);
assert_eq!(exit_success, true); assert_eq!(exit_success, true);
@ -28,13 +28,13 @@ fn test_mkdir_mkdir() {
#[test] #[test]
fn test_mkdir_dup_dir() { fn test_mkdir_dup_dir() {
cleanup(test_dir2); 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(); let exit_success = prog.unwrap().success();
if !exit_success { if !exit_success {
cleanup(test_dir2); cleanup(test_dir2);
fail!(); 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(); let exit_success2 = prog2.unwrap().success();
cleanup(test_dir2); cleanup(test_dir2);
assert_eq!(exit_success2, false); assert_eq!(exit_success2, false);
@ -43,7 +43,7 @@ fn test_mkdir_dup_dir() {
#[test] #[test]
fn test_mkdir_mode() { fn test_mkdir_mode() {
cleanup(test_dir3); 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(); let exit_success = prog.unwrap().success();
cleanup(test_dir3); cleanup(test_dir3);
assert_eq!(exit_success, true); assert_eq!(exit_success, true);
@ -52,7 +52,7 @@ fn test_mkdir_mode() {
#[test] #[test]
fn test_mkdir_parent() { fn test_mkdir_parent() {
cleanup(test_dir4); 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(); let exit_success = prog.unwrap().success();
cleanup(test_dir4); cleanup(test_dir4);
assert_eq!(exit_success, true); assert_eq!(exit_success, true);
@ -61,7 +61,7 @@ fn test_mkdir_parent() {
#[test] #[test]
fn test_mkdir_no_parent() { fn test_mkdir_no_parent() {
cleanup(test_dir5); 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(); let exit_success = prog.unwrap().success();
cleanup(test_dir5); cleanup(test_dir5);
assert_eq!(exit_success, false); assert_eq!(exit_success, false);

View file

@ -1,29 +1,30 @@
use std::{run,str}; use std::io::process::Process;
use std::str;
#[test] #[test]
fn test_count_up() { 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(); let out = str::from_utf8(p.output).unwrap().into_owned();
assert_eq!(out, ~"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n"); assert_eq!(out, ~"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n");
} }
#[test] #[test]
fn test_count_down() { 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(); let out = str::from_utf8(p.output).unwrap().into_owned();
assert_eq!(out, ~"5\n4\n3\n2\n1\n"); assert_eq!(out, ~"5\n4\n3\n2\n1\n");
} }
#[test] #[test]
fn test_separator_and_terminator() { 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(); let out = str::from_utf8(p.output).unwrap().into_owned();
assert_eq!(out, ~"2,3,4,5,6!"); assert_eq!(out, ~"2,3,4,5,6!");
} }
#[test] #[test]
fn test_equalize_widths() { 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(); let out = str::from_utf8(p.output).unwrap().into_owned();
assert_eq!(out, ~"05\n06\n07\n08\n09\n10\n"); assert_eq!(out, ~"05\n06\n07\n08\n09\n10\n");
} }

View file

@ -1,4 +1,5 @@
use std::{run, io}; use std::io;
use std::io::process::Process;
static PROG: &'static str = "build/truncate"; static PROG: &'static str = "build/truncate";
static TFILE1: &'static str = "truncate_test_1"; static TFILE1: &'static str = "truncate_test_1";
@ -14,7 +15,7 @@ fn make_file(name: &str) -> io::File {
#[test] #[test]
fn test_increase_file_size() { fn test_increase_file_size() {
let mut file = make_file(TFILE1); 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!(); fail!();
} }
file.seek(0, io::SeekEnd); file.seek(0, io::SeekEnd);
@ -28,7 +29,7 @@ fn test_increase_file_size() {
fn test_decrease_file_size() { fn test_decrease_file_size() {
let mut file = make_file(TFILE2); let mut file = make_file(TFILE2);
file.write(bytes!("1234567890")); 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!(); fail!();
} }
file.seek(0, io::SeekEnd); file.seek(0, io::SeekEnd);