dev/test tools to separate crate

This commit is contained in:
Nikolay Volf
2016-02-19 17:18:20 +03:00
parent 1866174327
commit fed90c126e
18 changed files with 809 additions and 74 deletions

View File

@@ -31,6 +31,10 @@ json-tests = { path = "json-tests" }
target_info = "0.1.0"
igd = "0.4.2"
[dev-dependencies]
ethcore-devtools = { path = "../devtools" }
[features]
default = []
dev = ["clippy"]
test = []

View File

@@ -1030,7 +1030,7 @@ mod file_tests {
mod directory_tests {
use super::{KeyDirectory, new_uuid, uuid_to_string, KeyFileContent, KeyFileCrypto, MAX_CACHE_USAGE_TRACK};
use common::*;
use tests::helpers::*;
use devtools::*;
#[test]
fn key_directory_locates_keys() {
@@ -1110,7 +1110,7 @@ mod directory_tests {
mod specs {
use super::*;
use common::*;
use tests::helpers::*;
use devtools::*;
#[test]
fn can_initiate_key_directory() {

View File

@@ -70,7 +70,7 @@ impl SecretStore {
}
#[cfg(test)]
fn new_test(path: &::tests::helpers::RandomTempPath) -> SecretStore {
fn new_test(path: &::devtools::RandomTempPath) -> SecretStore {
SecretStore {
directory: KeyDirectory::new(path.as_path())
}
@@ -203,7 +203,7 @@ mod vector_tests {
#[cfg(test)]
mod tests {
use super::*;
use tests::helpers::*;
use devtools::*;
use common::*;
#[test]

View File

@@ -106,6 +106,8 @@ extern crate serde;
#[macro_use]
extern crate log as rlog;
extern crate igd;
#[cfg(test)]
extern crate ethcore_devtools as devtools;
pub mod standard;
#[macro_use]
@@ -160,5 +162,3 @@ pub use network::*;
pub use io::*;
pub use log::*;
#[cfg(test)]
mod tests;

View File

@@ -1,31 +0,0 @@
use common::*;
use std::path::PathBuf;
use std::fs::{remove_dir_all};
use std::env;
pub struct RandomTempPath {
path: PathBuf
}
impl RandomTempPath {
pub fn create_dir() -> RandomTempPath {
let mut dir = env::temp_dir();
dir.push(H32::random().hex());
fs::create_dir_all(dir.as_path()).unwrap();
RandomTempPath {
path: dir.clone()
}
}
pub fn as_path(&self) -> &PathBuf {
&self.path
}
}
impl Drop for RandomTempPath {
fn drop(&mut self) {
if let Err(e) = remove_dir_all(self.as_path()) {
panic!("failed to remove temp directory, probably something failed to destroyed ({})", e);
}
}
}

View File

@@ -1 +0,0 @@
pub mod helpers;