tests: consolidate into one crate

The main motivation is to move toward running those tests for a specific
target, that is, if a test won't run on Windows, then we shouldn't build
it. This was previously the default behavior and prevented a successful
run on AppVeyor.

I borrowed this pattern from the tests in the Cargo project.
This commit is contained in:
Joseph Crail
2016-05-22 03:46:54 -04:00
parent dfa8777540
commit 7ef4bb37a8
56 changed files with 128 additions and 207 deletions
Generated
+26
View File
@@ -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",
@@ -207,6 +209,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"
@@ -323,6 +335,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"
@@ -481,6 +498,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"
+3
View File
@@ -192,3 +192,6 @@ tempdir="*"
[[bin]]
name = "uutils"
path = "src/uutils/uutils.rs"
[[test]]
name = "tests"
+1 -1
View File
@@ -19,4 +19,4 @@ artifacts:
name: uutils.exe
test_script:
- cargo test --no-fail-fast --features generic --no-default-features
- cargo test --no-fail-fast
+5 -5
View File
@@ -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";
@@ -54,15 +52,17 @@ macro_rules! assert_no_error(
#[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);
)*
-3
View File
@@ -1,6 +1,3 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "base64";
+1 -3
View File
@@ -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() {
-3
View File
@@ -1,6 +1,3 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "cat";
+10 -14
View File
@@ -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));
}
-3
View File
@@ -1,6 +1,3 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "cksum";
+1 -3
View File
@@ -1,8 +1,6 @@
#[macro_use]
mod common;
use common::util::testing;
use std::ffi::OsStr;
static UTIL_NAME: &'static str = "comm";
fn comm<A: AsRef<OsStr>, B: AsRef<str>>(args: &[A],
-3
View File
@@ -1,6 +1,3 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "cp";
-3
View File
@@ -1,6 +1,3 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "cut";
@@ -1,6 +1,3 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "dircolors";
@@ -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);
-3
View File
@@ -1,6 +1,3 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "echo";
-3
View File
@@ -1,6 +1,3 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "env";
-3
View File
@@ -1,6 +1,3 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "expr";
-10
View File
@@ -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))
-4
View File
@@ -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);
-3
View File
@@ -1,6 +1,3 @@
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "fold";

Some files were not shown because too many files have changed in this diff Show More