diff --git a/mkuutils.rs b/mkuutils.rs index 48f167360..2d9dfa01a 100644 --- a/mkuutils.rs +++ b/mkuutils.rs @@ -39,7 +39,11 @@ fn main() { util_map.push_str("map.insert(\"false\", uufalse as fn(Vec) -> i32);\n"); }, _ => { - crates.push_str(&(format!("extern crate {0} as uu{0};\n", prog))[..]); + if prog == "test" { + crates.push_str(&(format!("extern crate uu{0} as uu{0};\n", prog))[..]); + } else { + crates.push_str(&(format!("extern crate {0} as uu{0};\n", prog))[..]); + } util_map.push_str(&(format!("map.insert(\"{prog}\", uu{prog}::uumain as fn(Vec) -> i32);\n", prog = prog))[..]); } } diff --git a/src/test/test.rs b/src/test/test.rs index 5251a997e..f9ef059e7 100644 --- a/src/test/test.rs +++ b/src/test/test.rs @@ -1,5 +1,5 @@ #![crate_name = "test"] -#![feature(core, os, std_misc)] +#![feature(convert)] /* * This file is part of the uutils coreutils package. @@ -13,16 +13,16 @@ extern crate libc; use std::collections::HashMap; -use std::ffi::CString; -use std::os::{args_as_bytes}; +use std::ffi::{CString, OsString}; +use std::env::{args_os}; use std::str::{from_utf8}; static NAME: &'static str = "test"; // TODO: decide how to handle non-UTF8 input for all the utils pub fn uumain(_: Vec) -> i32 { - let args = args_as_bytes(); - let args: Vec<&[u8]> = args.iter().map(|a| a.as_slice()).collect(); + let args = args_os().collect::>(); + let args = args.iter().map(|a| a.to_bytes().unwrap()).collect::>(); if args.len() == 0 { return 2; } @@ -30,7 +30,7 @@ pub fn uumain(_: Vec) -> i32 { if !args[0].ends_with(NAME.as_bytes()) { &args[1..] } else { - args.as_slice() + &args[..] }; let args = match args[0] { b"[" => match args[args.len() - 1] { @@ -83,6 +83,7 @@ fn two(args: &[&[u8]], error: &mut bool) -> bool { fn three(args: &[&[u8]], error: &mut bool) -> bool { match args[1] { b"=" => args[0] == args[2], + b"==" => args[0] == args[2], b"!=" => args[0] != args[2], b"-eq" => integers(args[0], args[2], IntegerCondition::Equal), b"-ne" => integers(args[0], args[2], IntegerCondition::Unequal), @@ -191,6 +192,7 @@ fn dispatch_four(args: &mut &[&[u8]], error: &mut bool) -> (bool, usize) { } } +#[derive(Clone, Copy)] enum Precedence { Unknown = 0, Paren, // FIXME: this is useless (parentheses have not been implemented) @@ -201,8 +203,6 @@ enum Precedence { UnOp } -impl Copy for Precedence {} - fn parse_expr(mut args: &[&[u8]], error: &mut bool) -> bool { if args.len() == 0 { false diff --git a/test/test.rs b/test/test.rs index 480d0aa3f..b792538ea 100644 --- a/test/test.rs +++ b/test/test.rs @@ -1,6 +1,13 @@ -#![allow(unstable)] +/* + * This file is part of the uutils coreutils package. + * + * (c) mahkoh (ju.orth [at] gmail [dot] com) + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -use std::old_io::process::Command; +use std::process::Command; static EXE: &'static str = "./test"; @@ -26,6 +33,5 @@ fn test_op_prec_and_or_2() { #[test] fn test_or_as_filename() { let status = Command::new(EXE).arg("x").arg("-a").arg("-z").arg("-o").status(); - assert!(status.unwrap().matches_exit_status(1)); + assert_eq!(status.unwrap().code(), Some(1)); } -