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

Merge pull request #940 from knight42/cleanup-tests

Cleanup tests
This commit is contained in:
mpkh 2016-08-06 21:51:30 +04:00 committed by GitHub
commit b85b8dc18c
11 changed files with 18 additions and 44 deletions

View file

@ -192,14 +192,8 @@ yes = { optional=true, path="src/yes" }
[dev-dependencies]
time = "*"
kernel32-sys = "*"
winapi = "*"
filetime = "*"
libc = "*"
memchr = "*"
primal = "*"
aho-corasick= "*"
regex-syntax= "*"
regex="*"
rand="*"
tempdir="*"

0
tests/common/macros.rs Executable file → Normal file
View file

9
tests/common/util.rs Executable file → Normal file
View file

@ -1,4 +1,5 @@
#![allow(dead_code)]
extern crate tempdir;
use std::env;
use std::fs::{self, File, OpenOptions};
@ -14,7 +15,7 @@ use std::ffi::OsStr;
use std::rc::Rc;
use std::thread::sleep;
use std::time::Duration;
use tempdir::TempDir;
use self::tempdir::TempDir;
#[cfg(windows)]
static PROGNAME: &'static str = "uutils.exe";
@ -64,7 +65,7 @@ impl CmdResult {
assert!(!self.success);
Box::new(self)
}
/// asserts that the command resulted in empty (zero-length) stderr stream output
/// generally, it's better to use stdout_only() instead,
/// but you might find yourself using this function if
@ -74,7 +75,7 @@ impl CmdResult {
assert_eq!(0, self.stderr.len());
Box::new(self)
}
/// asserts that the command resulted in empty (zero-length) stderr stream output
/// unless asserting there was neither stdout or stderr, stderr_only is usually a better choice
/// generally, it's better to use stderr_only() instead,
@ -93,7 +94,7 @@ impl CmdResult {
assert_eq!(String::from(msg.as_ref()).trim_right(), self.stdout.trim_right());
Box::new(self)
}
/// like stdout_is(...), but expects the contents of the file at the provided relative path
pub fn stdout_is_fixture<T: AsRef<OsStr>>(&self, file_rel_path: T) -> Box<&CmdResult> {
let contents = read_scenario_fixture(&self.tmpd, file_rel_path);

View file

@ -8,9 +8,14 @@
//
use common::util::*;
use rand::{weak_rng, Rng};
use rand::distributions::{IndependentSample, Range};
use sieve::Sieve;
#[path="../src/factor/sieve.rs"]
mod sieve;
use self::sieve::Sieve;
extern crate rand;
use self::rand::{weak_rng, Rng};
use self::rand::distributions::{IndependentSample, Range};
const NUM_PRIMES: usize = 10000;
const LOG_PRIMES: f64 = 14.0; // ceil(log2(NUM_PRIMES))

View file

@ -1,10 +1,3 @@
extern crate libc;
extern crate time;
extern crate kernel32;
extern crate winapi;
extern crate filetime;
use self::filetime::*;
use common::util::*;
use std::os::unix::fs::PermissionsExt;
@ -17,7 +10,7 @@ fn at_and_ucmd() -> (AtPath, UCommand) {
#[test]
fn test_install_help() {
let (at, mut ucmd) = at_and_ucmd();
let (_, mut ucmd) = at_and_ucmd();
let result = ucmd.arg("--help").run();

View file

@ -1,5 +1,3 @@
extern crate libc;
use common::util::*;
static UTIL_NAME: &'static str = "link";

View file

@ -1,5 +1,6 @@
use common::util::*;
use tempdir::TempDir;
extern crate tempdir;
use self::tempdir::TempDir;
static UTIL_NAME: &'static str = "mktemp";

View file

@ -1,7 +1,4 @@
extern crate libc;
extern crate time;
extern crate kernel32;
extern crate winapi;
extern crate filetime;
use self::filetime::*;

View file

@ -1,5 +1,3 @@
extern crate libc;
use common::util::*;
static UTIL_NAME: &'static str = "rmdir";

View file

@ -4,8 +4,8 @@ extern crate regex;
use std::fs::{File, read_dir};
use std::io::{Read, Write};
use std::path::Path;
use rand::{Rng, thread_rng};
use regex::Regex;
use self::rand::{Rng, thread_rng};
use self::regex::Regex;
use common::util::*;
static UTIL_NAME: &'static str = "split";

View file

@ -1,19 +1,6 @@
extern crate filetime;
extern crate libc;
extern crate rand;
extern crate regex;
extern crate tempdir;
extern crate time;
#[cfg(windows)] extern crate kernel32;
#[cfg(windows)] extern crate winapi;
#[macro_use]
mod common;
#[path="../src/factor/sieve.rs"]
mod sieve;
// For conditional compilation
macro_rules! unix_only {
($($fea:expr, $m:ident);+) => {