use stdlib TempDir

without.crypto
Dan Burkert 10 years ago
parent 71ea09c938
commit 735bd511c9
  1. 1
      Cargo.toml
  2. 15
      src/cursor.rs
  3. 14
      src/environment.rs
  4. 9
      src/lib.rs
  5. 19
      src/transaction.rs

@ -23,5 +23,4 @@ version = "0.3.0"
bitflags = "*"
[dev-dependencies]
tempdir = "*"
rand = "*"

@ -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();

@ -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());

@ -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();
{

@ -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<Environment> = 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

Loading…
Cancel
Save