diff --git a/Cargo.toml b/Cargo.toml index 1565f51..43d21fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,5 +23,4 @@ version = "0.3.0" bitflags = "*" [dev-dependencies] -tempdir = "*" rand = "*" diff --git a/src/cursor.rs b/src/cursor.rs index f2b16af..069b8df 100644 --- a/src/cursor.rs +++ b/src/cursor.rs @@ -291,7 +291,7 @@ impl <'txn> Iterator for IterDup<'txn> { mod test { use std::old_io as io; - use std::ptr; + use std::{fs, ptr}; use test::{Bencher, black_box}; use ffi::*; @@ -299,13 +299,12 @@ mod test { use environment::*; use flags::*; use super::*; - use tempdir; use test_utils::*; use transaction::*; #[test] fn test_get() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.open_db(None).unwrap(); @@ -335,7 +334,7 @@ mod test { #[test] fn test_get_dup() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.create_db(None, DUP_SORT).unwrap(); @@ -381,7 +380,7 @@ mod test { #[test] fn test_get_dupfixed() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.create_db(None, DUP_SORT | DUP_FIXED).unwrap(); @@ -403,7 +402,7 @@ mod test { #[test] fn test_iter() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.open_db(None).unwrap(); @@ -435,7 +434,7 @@ mod test { #[test] fn test_iter_dup() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.create_db(None, DUP_SORT).unwrap(); @@ -482,7 +481,7 @@ mod test { #[test] fn test_put_del() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.open_db(None).unwrap(); diff --git a/src/environment.rs b/src/environment.rs index 0c28946..f0e1a05 100644 --- a/src/environment.rs +++ b/src/environment.rs @@ -243,15 +243,15 @@ impl EnvironmentBuilder { mod test { use std::old_io as io; + use std::fs; use flags::*; - use tempdir; use super::*; #[test] fn test_open() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); // opening non-existent env with read-only should fail assert!(Environment::new().set_flags(READ_ONLY) @@ -269,7 +269,7 @@ mod test { #[test] fn test_begin_txn() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); { // writable environment let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); @@ -290,7 +290,7 @@ mod test { #[test] fn test_open_db() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().set_max_dbs(1) .open(dir.path(), io::USER_RWX) .unwrap(); @@ -301,7 +301,7 @@ mod test { #[test] fn test_create_db() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().set_max_dbs(11) .open(dir.path(), io::USER_RWX) .unwrap(); @@ -312,7 +312,7 @@ mod test { #[test] fn test_close_database() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let mut env = Environment::new().set_max_dbs(10) .open(dir.path(), io::USER_RWX) .unwrap(); @@ -324,7 +324,7 @@ mod test { #[test] fn test_sync() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); { let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); assert!(env.sync(true).is_ok()); diff --git a/src/lib.rs b/src/lib.rs index b7dcacc..8caa96c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,13 +2,12 @@ //! [Symas Lightning Memory-Mapped Database (LMDB)](http://symas.com/mdb/). #![feature(core, libc, old_io, optin_builtin_traits, path, std_misc, unsafe_destructor)] -#![cfg_attr(test, feature(test))] +#![cfg_attr(test, feature(fs, tempdir, test))] extern crate libc; extern crate "lmdb-sys" as ffi; #[cfg(test)] extern crate rand; -#[cfg(test)] extern crate tempdir; #[cfg(test)] extern crate test; #[macro_use] extern crate bitflags; @@ -63,7 +62,7 @@ mod test_utils { use std::old_io as io; - use tempdir; + use std::fs; use super::*; @@ -75,8 +74,8 @@ mod test_utils { format!("data{}", n) } - pub fn setup_bench_db<'a>(num_rows: u32) -> (tempdir::TempDir, Environment) { - let dir = tempdir::TempDir::new("test").unwrap(); + pub fn setup_bench_db<'a>(num_rows: u32) -> (fs::TempDir, Environment) { + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); { diff --git a/src/transaction.rs b/src/transaction.rs index 3be3ab5..b518a00 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -363,7 +363,7 @@ impl <'env> Transaction<'env> for RwTransaction<'env> { mod test { use std::old_io as io; - use std::ptr; + use std::{fs, ptr}; use rand::{Rng, XorShiftRng}; use std::sync::{Arc, Barrier, Future}; use test::{Bencher, black_box}; @@ -374,12 +374,11 @@ mod test { use error::*; use flags::*; use super::*; - use tempdir; use test_utils::*; #[test] fn test_put_get_del() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.open_db(None).unwrap(); @@ -401,7 +400,7 @@ mod test { #[test] fn test_reserve() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.open_db(None).unwrap(); @@ -422,7 +421,7 @@ mod test { #[test] fn test_inactive_txn() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.open_db(None).unwrap(); @@ -440,7 +439,7 @@ mod test { #[test] fn test_nested_txn() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.open_db(None).unwrap(); @@ -460,7 +459,7 @@ mod test { #[test] fn test_clear_db() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().open(dir.path(), io::USER_RWX).unwrap(); let db = env.open_db(None).unwrap(); @@ -483,7 +482,7 @@ mod test { #[test] fn test_drop_db() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Environment::new().set_max_dbs(2) .open(dir.path(), io::USER_RWX).unwrap(); let db = env.create_db(Some("test"), DatabaseFlags::empty()).unwrap(); @@ -504,7 +503,7 @@ mod test { #[test] fn test_concurrent_readers_single_writer() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env: Arc = Arc::new(Environment::new().open(dir.path(), io::USER_RWX).unwrap()); let n = 10usize; // Number of concurrent readers @@ -546,7 +545,7 @@ mod test { #[test] fn test_concurrent_writers() { - let dir = tempdir::TempDir::new("test").unwrap(); + let dir = fs::TempDir::new("test").unwrap(); let env = Arc::new(Environment::new().open(dir.path(), io::USER_RWX).unwrap()); let n = 10usize; // Number of concurrent writers