diff --git a/Cargo.lock b/Cargo.lock index 02b1168d9..d2464e9f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,6 +12,7 @@ dependencies = [ "comm 0.0.1", "cp 0.0.1", "cut 0.0.1", + "dircolors 0.0.1", "dirname 0.0.1", "du 0.0.1", "echo 0.0.1", @@ -39,6 +40,7 @@ dependencies = [ "memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "mkdir 0.0.1", "mkfifo 0.0.1", + "mknod 0.0.1", "mktemp 0.0.1", "mv 0.0.1", "nice 0.0.1", @@ -208,6 +210,16 @@ dependencies = [ "uucore 0.0.1", ] +[[package]] +name = "dircolors" +version = "0.0.1" +dependencies = [ + "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "uucore 0.0.1", +] + [[package]] name = "dirname" version = "0.0.1" @@ -324,6 +336,11 @@ name = "getopts" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "glob" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "groups" version = "0.0.1" @@ -482,6 +499,15 @@ dependencies = [ "uucore 0.0.1", ] +[[package]] +name = "mknod" +version = "0.0.1" +dependencies = [ + "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "uucore 0.0.1", +] + [[package]] name = "mktemp" version = "0.0.1" diff --git a/Cargo.toml b/Cargo.toml index ad3e8b78c..a6a820e48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -194,3 +194,6 @@ tempdir="*" [[bin]] name = "uutils" path = "src/uutils/uutils.rs" + +[[test]] +name = "tests" diff --git a/appveyor.yml b/appveyor.yml index 725523500..5f3e0b527 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -12,12 +12,9 @@ install: - cargo -V build_script: - - cargo build --features generic --no-default-features - - 7z a -tzip uutils.zip .\target\release\deps\*.exe + - cargo build --release --features generic --no-default-features artifacts: - - path: uutils.zip - name: zipfile - path: target\release\uutils.exe name: uutils.exe diff --git a/src/whoami/platform/windows.rs b/src/whoami/platform/windows.rs index f2d627431..d52c2b063 100644 --- a/src/whoami/platform/windows.rs +++ b/src/whoami/platform/windows.rs @@ -13,7 +13,6 @@ extern crate uucore; use std::io::{Error, Result}; use std::mem; -use std::os::windows::ffi::OsStringExt; use uucore::wide::FromWide; pub unsafe fn getusername() -> Result { diff --git a/tests/common/util.rs b/tests/common/util.rs index c233635dc..1e3d42a14 100755 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -1,7 +1,5 @@ #![allow(dead_code)] -extern crate tempdir; - use std::env; use std::fs::{self, File, OpenOptions}; use std::io::{Read, Write, Result}; @@ -14,10 +12,10 @@ use std::path::{Path, PathBuf}; use std::process::{Command, Stdio, Child}; use std::str::from_utf8; use std::ffi::OsStr; -use self::tempdir::TempDir; use std::rc::Rc; use std::thread::sleep; use std::time::Duration; +use tempdir::TempDir; #[cfg(windows)] static PROGNAME: &'static str = "target\\debug\\uutils.exe"; @@ -71,15 +69,17 @@ pub fn repeat_str(s: &str, n: u32) -> String { #[macro_export] macro_rules! path_concat { ($e:expr, ..$n:expr) => {{ + use std::path::PathBuf; let n = $n; - let mut pb = std::path::PathBuf::new(); + let mut pb = PathBuf::new(); for _ in 0..n { pb.push($e); } pb.to_str().unwrap().to_owned() }}; ($($e:expr),*) => {{ - let mut pb = std::path::PathBuf::new(); + use std::path::PathBuf; + let mut pb = PathBuf::new(); $( pb.push($e); )* diff --git a/tests/base64.rs b/tests/test_base64.rs similarity index 99% rename from tests/base64.rs rename to tests/test_base64.rs index 1e9482e2d..ff3527eff 100644 --- a/tests/base64.rs +++ b/tests/test_base64.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "base64"; diff --git a/tests/basename.rs b/tests/test_basename.rs similarity index 98% rename from tests/basename.rs rename to tests/test_basename.rs index 4399e4d9c..9a61769bb 100644 --- a/tests/basename.rs +++ b/tests/test_basename.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "basename"; @@ -44,6 +41,7 @@ fn expect_error(input: Vec<&str>, expected_stdout: &str) { assert!(results.stderr.len() > 0); assert_eq!(expected_stdout, results.stdout.trim_right()); } + #[cfg_attr(not(feature="test_unimplemented"),ignore)] #[test] fn test_multiple_param() { diff --git a/tests/cat.rs b/tests/test_cat.rs similarity index 98% rename from tests/cat.rs rename to tests/test_cat.rs index af538f6ba..909ec6056 100644 --- a/tests/cat.rs +++ b/tests/test_cat.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "cat"; diff --git a/tests/chmod.rs b/tests/test_chmod.rs similarity index 88% rename from tests/chmod.rs rename to tests/test_chmod.rs index a00cb5417..4efb24d8f 100644 --- a/tests/chmod.rs +++ b/tests/test_chmod.rs @@ -1,33 +1,29 @@ -#[macro_use] -mod common; - -use std::os::unix::raw::mode_t; -use std::os::unix::fs::PermissionsExt; -use std::os::unix::fs::OpenOptionsExt; use common::util::*; +use std::fs::{metadata, OpenOptions, set_permissions}; +use std::os::unix::fs::{OpenOptionsExt, PermissionsExt}; static UTIL_NAME: &'static str = "chmod"; static TEST_FILE: &'static str = "file"; static REFERENCE_FILE: &'static str = "reference"; -static REFERENCE_PERMS: mode_t = 0o247; +static REFERENCE_PERMS: u32 = 0o247; struct TestCase { args: Vec<&'static str>, - before: mode_t, - after: mode_t + before: u32, + after: u32 } -fn mkfile(file: &str, mode: mode_t) { - std::fs::OpenOptions::new().mode(mode).create(true).write(true).open(file).unwrap(); - let mut perms = std::fs::metadata(file).unwrap().permissions(); +fn mkfile(file: &str, mode: u32) { + OpenOptions::new().mode(mode).create(true).write(true).open(file).unwrap(); + let mut perms = metadata(file).unwrap().permissions(); perms.set_mode(mode); - std::fs::set_permissions(file, perms).unwrap(); + set_permissions(file, perms).unwrap(); } fn run_single_test(test: &TestCase, at: AtPath, mut ucmd: UCommand) { mkfile(&at.plus_as_string(TEST_FILE), test.before); let perms = at.metadata(TEST_FILE).permissions().mode(); - if perms != test.before{ + if perms != test.before { panic!(format!("{}: expected: {:o} got: {:o}", "setting permissions failed", test.after, perms)); } diff --git a/tests/cksum.rs b/tests/test_cksum.rs similarity index 97% rename from tests/cksum.rs rename to tests/test_cksum.rs index f41b569d8..9ed58adca 100644 --- a/tests/cksum.rs +++ b/tests/test_cksum.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "cksum"; diff --git a/tests/comm.rs b/tests/test_comm.rs similarity index 99% rename from tests/comm.rs rename to tests/test_comm.rs index 14ff0c726..fff1cf232 100644 --- a/tests/comm.rs +++ b/tests/test_comm.rs @@ -1,8 +1,6 @@ -#[macro_use] -mod common; - use common::util::testing; use std::ffi::OsStr; + static UTIL_NAME: &'static str = "comm"; fn comm, B: AsRef>(args: &[A], diff --git a/tests/cp.rs b/tests/test_cp.rs similarity index 96% rename from tests/cp.rs rename to tests/test_cp.rs index 4e3089314..d1952ae0f 100644 --- a/tests/cp.rs +++ b/tests/test_cp.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "cp"; diff --git a/tests/cut.rs b/tests/test_cut.rs similarity index 98% rename from tests/cut.rs rename to tests/test_cut.rs index 216513f8a..afc87fb91 100644 --- a/tests/cut.rs +++ b/tests/test_cut.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "cut"; diff --git a/tests/dircolors.rs b/tests/test_dircolors.rs similarity index 98% rename from tests/dircolors.rs rename to tests/test_dircolors.rs index 7a33ab95e..5853baa67 100644 --- a/tests/dircolors.rs +++ b/tests/test_dircolors.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "dircolors"; diff --git a/tests/dirname.rs b/tests/test_dirname.rs similarity index 97% rename from tests/dirname.rs rename to tests/test_dirname.rs index fe7f368eb..570035963 100644 --- a/tests/dirname.rs +++ b/tests/test_dirname.rs @@ -1,11 +1,7 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "dirname"; - #[test] fn test_path_with_trailing_slashes() { let (_, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/echo.rs b/tests/test_echo.rs similarity index 96% rename from tests/echo.rs rename to tests/test_echo.rs index efc36cf8d..e8007df45 100644 --- a/tests/echo.rs +++ b/tests/test_echo.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "echo"; diff --git a/tests/env.rs b/tests/test_env.rs similarity index 98% rename from tests/env.rs rename to tests/test_env.rs index e59a5aba6..f374bbd94 100644 --- a/tests/env.rs +++ b/tests/test_env.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "env"; diff --git a/tests/expr.rs b/tests/test_expr.rs similarity index 98% rename from tests/expr.rs rename to tests/test_expr.rs index 72d07c499..bdce876aa 100644 --- a/tests/expr.rs +++ b/tests/test_expr.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "expr"; diff --git a/tests/factor.rs b/tests/test_factor.rs similarity index 99% rename from tests/factor.rs rename to tests/test_factor.rs index 1da6a41cd..06d27e9fc 100644 --- a/tests/factor.rs +++ b/tests/test_factor.rs @@ -7,21 +7,11 @@ // that was distributed with this source code. // -#[macro_use] -mod common; - use common::util::*; - -extern crate libc; -extern crate rand; - use rand::{weak_rng, Rng}; use rand::distributions::{IndependentSample, Range}; use sieve::Sieve; -#[path="../src/factor/sieve.rs"] -mod sieve; - const NUM_PRIMES: usize = 10000; const LOG_PRIMES: f64 = 14.0; // ceil(log2(NUM_PRIMES)) diff --git a/tests/false.rs b/tests/test_false.rs similarity index 89% rename from tests/false.rs rename to tests/test_false.rs index afa19b339..ecd11c5e3 100644 --- a/tests/false.rs +++ b/tests/test_false.rs @@ -1,11 +1,7 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "false"; - #[test] fn test_exit_code() { let (_, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/fold.rs b/tests/test_fold.rs similarity index 97% rename from tests/fold.rs rename to tests/test_fold.rs index f24c035ce..3a0de02f9 100644 --- a/tests/fold.rs +++ b/tests/test_fold.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "fold"; diff --git a/tests/hashsum.rs b/tests/test_hashsum.rs similarity index 97% rename from tests/hashsum.rs rename to tests/test_hashsum.rs index d653e5422..7d068c7e8 100644 --- a/tests/hashsum.rs +++ b/tests/test_hashsum.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - macro_rules! get_hash( ($str:expr) => ( $str.split(' ').collect::>()[0] diff --git a/tests/head.rs b/tests/test_head.rs similarity index 98% rename from tests/head.rs rename to tests/test_head.rs index 19adbf6a0..139c668ac 100644 --- a/tests/head.rs +++ b/tests/test_head.rs @@ -1,13 +1,9 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "head"; static INPUT: &'static str = "lorem_ipsum.txt"; - #[test] fn test_stdin_default() { let (at, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/link.rs b/tests/test_link.rs similarity index 98% rename from tests/link.rs rename to tests/test_link.rs index b94fbeb28..82f96b497 100644 --- a/tests/link.rs +++ b/tests/test_link.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - extern crate libc; use common::util::*; diff --git a/tests/ln.rs b/tests/test_ln.rs similarity index 99% rename from tests/ln.rs rename to tests/test_ln.rs index 826ac0f29..c6781277c 100644 --- a/tests/ln.rs +++ b/tests/test_ln.rs @@ -1,12 +1,7 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "ln"; - - #[test] fn test_symlink_existing_file() { let (at, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/ls.rs b/tests/test_ls.rs similarity index 73% rename from tests/ls.rs rename to tests/test_ls.rs index 36d98eea1..a6d574e60 100644 --- a/tests/ls.rs +++ b/tests/test_ls.rs @@ -1,16 +1,13 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "ls"; #[test] fn test_ls_ls() { - let (at, mut ucmd) = testing(UTIL_NAME); + let (_, mut ucmd) = testing(UTIL_NAME); let result = ucmd.run(); let exit_success = result.success; assert_eq!(exit_success, true); -} \ No newline at end of file +} diff --git a/tests/mkdir.rs b/tests/test_mkdir.rs similarity index 98% rename from tests/mkdir.rs rename to tests/test_mkdir.rs index e1b0dde90..f0c6581d7 100644 --- a/tests/mkdir.rs +++ b/tests/test_mkdir.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "mkdir"; @@ -11,7 +8,6 @@ static TEST_DIR3: &'static str = "mkdir_test3"; static TEST_DIR4: &'static str = "mkdir_test4/mkdir_test4_1"; static TEST_DIR5: &'static str = "mkdir_test5/mkdir_test5_1"; - #[test] fn test_mkdir_mkdir() { let (_, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/mktemp.rs b/tests/test_mktemp.rs similarity index 98% rename from tests/mktemp.rs rename to tests/test_mktemp.rs index fd933a20b..8105dae6b 100644 --- a/tests/mktemp.rs +++ b/tests/test_mktemp.rs @@ -1,8 +1,5 @@ -#[macro_use] -mod common; - use common::util::*; -use common::util::tempdir::TempDir; +use tempdir::TempDir; static UTIL_NAME: &'static str = "mktemp"; @@ -20,7 +17,6 @@ static TEST_TEMPLATE8: &'static str = "tempXXXla\\te"; const TMPDIR: &'static str = "TMPDIR"; - #[test] fn test_mktemp_mktemp() { let ts = TestSet::new(UTIL_NAME); diff --git a/tests/mv.rs b/tests/test_mv.rs similarity index 99% rename from tests/mv.rs rename to tests/test_mv.rs index d07b9d444..80f918ed8 100644 --- a/tests/mv.rs +++ b/tests/test_mv.rs @@ -1,13 +1,10 @@ -#[macro_use] -mod common; - extern crate libc; extern crate time; extern crate kernel32; extern crate winapi; extern crate filetime; -use filetime::*; +use self::filetime::*; use common::util::*; static UTIL_NAME: &'static str = "mv"; diff --git a/tests/nl.rs b/tests/test_nl.rs similarity index 98% rename from tests/nl.rs rename to tests/test_nl.rs index a555e4b09..fa731b310 100644 --- a/tests/nl.rs +++ b/tests/test_nl.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "nl"; diff --git a/tests/od.rs b/tests/test_od.rs similarity index 99% rename from tests/od.rs rename to tests/test_od.rs index d177d344c..625c3ae4e 100644 --- a/tests/od.rs +++ b/tests/test_od.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; use std::path::Path; use std::env; diff --git a/tests/paste.rs b/tests/test_paste.rs similarity index 93% rename from tests/paste.rs rename to tests/test_paste.rs index 66e052d96..0f9236abb 100644 --- a/tests/paste.rs +++ b/tests/test_paste.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "paste"; diff --git a/tests/printf.rs b/tests/test_printf.rs similarity index 99% rename from tests/printf.rs rename to tests/test_printf.rs index be3fae7fb..b30fb1515 100644 --- a/tests/printf.rs +++ b/tests/test_printf.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "printf"; diff --git a/tests/ptx.rs b/tests/test_ptx.rs similarity index 98% rename from tests/ptx.rs rename to tests/test_ptx.rs index 1aa1677eb..9f56dd93a 100644 --- a/tests/ptx.rs +++ b/tests/test_ptx.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "ptx"; diff --git a/tests/pwd.rs b/tests/test_pwd.rs similarity index 90% rename from tests/pwd.rs rename to tests/test_pwd.rs index 5ac5fcf43..49301f016 100644 --- a/tests/pwd.rs +++ b/tests/test_pwd.rs @@ -1,11 +1,7 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "pwd"; - #[test] fn test_default() { let (at, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/readlink.rs b/tests/test_readlink.rs similarity index 98% rename from tests/readlink.rs rename to tests/test_readlink.rs index 5cad3a0c4..887e55269 100644 --- a/tests/readlink.rs +++ b/tests/test_readlink.rs @@ -1,13 +1,9 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "readlink"; static GIBBERISH: &'static str = "supercalifragilisticexpialidocious"; - #[test] fn test_canonicalize() { let (at, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/realpath.rs b/tests/test_realpath.rs similarity index 96% rename from tests/realpath.rs rename to tests/test_realpath.rs index 479cdd7cc..66ea16f3b 100644 --- a/tests/realpath.rs +++ b/tests/test_realpath.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "realpath"; diff --git a/tests/rm.rs b/tests/test_rm.rs similarity index 99% rename from tests/rm.rs rename to tests/test_rm.rs index 2a5cd353e..3fcd835cb 100644 --- a/tests/rm.rs +++ b/tests/test_rm.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "rm"; diff --git a/tests/rmdir.rs b/tests/test_rmdir.rs similarity index 99% rename from tests/rmdir.rs rename to tests/test_rmdir.rs index d114d6eda..cf6a2732c 100644 --- a/tests/rmdir.rs +++ b/tests/test_rmdir.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - extern crate libc; use common::util::*; diff --git a/tests/seq.rs b/tests/test_seq.rs similarity index 96% rename from tests/seq.rs rename to tests/test_seq.rs index 755bd4ad6..655f36bb5 100644 --- a/tests/seq.rs +++ b/tests/test_seq.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "seq"; diff --git a/tests/sort.rs b/tests/test_sort.rs similarity index 97% rename from tests/sort.rs rename to tests/test_sort.rs index 5544290c8..3676d9e6c 100644 --- a/tests/sort.rs +++ b/tests/test_sort.rs @@ -1,11 +1,7 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "sort"; - #[test] fn test_numeric_floats_and_ints() { test_helper("numeric_floats_and_ints", "-n"); diff --git a/tests/split.rs b/tests/test_split.rs similarity index 99% rename from tests/split.rs rename to tests/test_split.rs index 0825a3e44..3e7d7c81b 100644 --- a/tests/split.rs +++ b/tests/test_split.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - extern crate rand; extern crate regex; @@ -13,8 +10,6 @@ use common::util::*; static UTIL_NAME: &'static str = "split"; - - fn random_chars(n: usize) -> String { thread_rng().gen_ascii_chars().take(n).collect::() } diff --git a/tests/stdbuf.rs b/tests/test_stdbuf.rs similarity index 94% rename from tests/stdbuf.rs rename to tests/test_stdbuf.rs index 053fc43c6..84ccdd834 100644 --- a/tests/stdbuf.rs +++ b/tests/test_stdbuf.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "stdbuf"; diff --git a/tests/sum.rs b/tests/test_sum.rs similarity index 98% rename from tests/sum.rs rename to tests/test_sum.rs index 967f2119d..d4445e7af 100644 --- a/tests/sum.rs +++ b/tests/test_sum.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "sum"; diff --git a/tests/tac.rs b/tests/test_tac.rs similarity index 98% rename from tests/tac.rs rename to tests/test_tac.rs index ee64c65ca..4ae6c4443 100644 --- a/tests/tac.rs +++ b/tests/test_tac.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "tac"; diff --git a/tests/tail.rs b/tests/test_tail.rs similarity index 96% rename from tests/tail.rs rename to tests/test_tail.rs index 591c69769..b3d211e2b 100644 --- a/tests/tail.rs +++ b/tests/test_tail.rs @@ -1,13 +1,9 @@ extern crate uu_tail; -use uu_tail::parse_size; - -use std::io::Read; -use std::io::Write; - -#[macro_use] -mod common; use common::util::*; +use std::char::from_digit; +use std::io::{Read, Write}; +use uu_tail::parse_size; static UTIL_NAME: &'static str = "tail"; @@ -110,14 +106,14 @@ fn test_bytes_big() { let mut big_input = at.make_scoped_file(FILE); for i in 0..BYTES { - let digit = std::char::from_digit((i % 10) as u32, 10).unwrap(); + let digit = from_digit((i % 10) as u32, 10).unwrap(); write!(&mut big_input, "{}", digit).expect("Could not write to FILE"); } big_input.flush().expect("Could not flush FILE"); let mut big_expected = at.make_scoped_file(EXPECTED_FILE); for i in (BYTES - N_ARG)..BYTES { - let digit = std::char::from_digit((i % 10) as u32, 10).unwrap(); + let digit = from_digit((i % 10) as u32, 10).unwrap(); write!(&mut big_expected, "{}", digit).expect("Could not write to EXPECTED_FILE"); } big_expected.flush().expect("Could not flush EXPECTED_FILE"); diff --git a/tests/test.rs b/tests/test_test.rs similarity index 98% rename from tests/test.rs rename to tests/test_test.rs index 842018f32..2ae982e77 100644 --- a/tests/test.rs +++ b/tests/test_test.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - // // This file is part of the uutils coreutils package. // @@ -14,7 +11,6 @@ use common::util::*; static UTIL_NAME: &'static str = "test"; - #[test] fn test_op_prec_and_or_1() { let (_, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/touch.rs b/tests/test_touch.rs similarity index 99% rename from tests/touch.rs rename to tests/test_touch.rs index 61f7982fa..9288b94ed 100644 --- a/tests/touch.rs +++ b/tests/test_touch.rs @@ -1,11 +1,8 @@ -#[macro_use] -mod common; - -extern crate time; extern crate filetime; +extern crate time; -use filetime::FileTime; use common::util::*; +use self::filetime::FileTime; static UTIL_NAME: &'static str = "touch"; diff --git a/tests/tr.rs b/tests/test_tr.rs similarity index 97% rename from tests/tr.rs rename to tests/test_tr.rs index f383aaa4a..2d4960c25 100644 --- a/tests/tr.rs +++ b/tests/test_tr.rs @@ -1,12 +1,7 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "tr"; - - #[test] fn test_toupper() { let (_, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/true.rs b/tests/test_true.rs similarity index 89% rename from tests/true.rs rename to tests/test_true.rs index f50e77a78..3f3ef1dc2 100644 --- a/tests/true.rs +++ b/tests/test_true.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "true"; diff --git a/tests/truncate.rs b/tests/test_truncate.rs similarity index 96% rename from tests/truncate.rs rename to tests/test_truncate.rs index d1406a979..bf8d5fa5e 100644 --- a/tests/truncate.rs +++ b/tests/test_truncate.rs @@ -1,8 +1,5 @@ -#[macro_use] -mod common; - -use std::io::{Seek, SeekFrom, Write}; use common::util::*; +use std::io::{Seek, SeekFrom, Write}; static UTIL_NAME: &'static str = "truncate"; diff --git a/tests/tsort.rs b/tests/test_tsort.rs similarity index 93% rename from tests/tsort.rs rename to tests/test_tsort.rs index 4bc388c44..21da1d150 100644 --- a/tests/tsort.rs +++ b/tests/test_tsort.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "tsort"; diff --git a/tests/unexpand.rs b/tests/test_unexpand.rs similarity index 99% rename from tests/unexpand.rs rename to tests/test_unexpand.rs index d51da4e98..d45f81762 100644 --- a/tests/unexpand.rs +++ b/tests/test_unexpand.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "unexpand"; diff --git a/tests/uniq.rs b/tests/test_uniq.rs similarity index 99% rename from tests/uniq.rs rename to tests/test_uniq.rs index af4f4c93e..3f223e8e7 100644 --- a/tests/uniq.rs +++ b/tests/test_uniq.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "uniq"; @@ -9,7 +6,6 @@ static INPUT: &'static str = "sorted.txt"; static SKIP_CHARS: &'static str = "skip-chars.txt"; static SKIP_FIELDS: &'static str = "skip-fields.txt"; - #[test] fn test_stdin_default() { let (at, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/unlink.rs b/tests/test_unlink.rs similarity index 98% rename from tests/unlink.rs rename to tests/test_unlink.rs index 2cc080f4f..d96e38ab5 100644 --- a/tests/unlink.rs +++ b/tests/test_unlink.rs @@ -1,11 +1,7 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "unlink"; - #[test] fn test_unlink_file() { let (at, mut ucmd) = testing(UTIL_NAME); diff --git a/tests/wc.rs b/tests/test_wc.rs similarity index 98% rename from tests/wc.rs rename to tests/test_wc.rs index a351ba0ce..6d66c81b3 100644 --- a/tests/wc.rs +++ b/tests/test_wc.rs @@ -1,6 +1,3 @@ -#[macro_use] -mod common; - use common::util::*; static UTIL_NAME: &'static str = "wc"; diff --git a/tests/tests.rs b/tests/tests.rs new file mode 100644 index 000000000..bae56caed --- /dev/null +++ b/tests/tests.rs @@ -0,0 +1,69 @@ +extern crate filetime; +extern crate libc; +extern crate rand; +extern crate regex; +extern crate tempdir; +extern crate time; +extern crate uu_tail; + +#[cfg(windows)] extern crate kernel32; +#[cfg(windows)] extern crate winapi; + +#[macro_use] +mod common; + +#[path="../src/factor/sieve.rs"] +mod sieve; + +#[cfg(unix)] mod test_chmod; +#[cfg(unix)] mod test_mv; +#[cfg(unix)] mod test_stdbuf; +#[cfg(unix)] mod test_touch; +#[cfg(unix)] mod test_unlink; + +mod test_base64; +mod test_basename; +mod test_cat; +mod test_cksum; +mod test_comm; +mod test_cp; +mod test_cut; +mod test_dircolors; +mod test_dirname; +mod test_echo; +mod test_env; +mod test_expr; +mod test_factor; +mod test_false; +mod test_fold; +mod test_hashsum; +mod test_head; +mod test_link; +mod test_ln; +mod test_ls; +mod test_mkdir; +mod test_mktemp; +mod test_nl; +mod test_od; +mod test_paste; +mod test_printf; +mod test_ptx; +mod test_pwd; +mod test_readlink; +mod test_realpath; +mod test_rm; +mod test_rmdir; +mod test_seq; +mod test_sort; +mod test_split; +mod test_sum; +mod test_tac; +mod test_tail; +mod test_test; +mod test_tr; +mod test_true; +mod test_truncate; +mod test_tsort; +mod test_unexpand; +mod test_uniq; +mod test_wc;