Skip to content

Commit

Permalink
Fixup Dependencies
Browse files Browse the repository at this point in the history
While reading through changes the new dependencies for tempdir and
lazy_static caught my eye. The first bit was that these should be marked
as `dev-dependencies` so that we're not forcing them onto users of
`tiledb-rs` that don't need them.

I've also removed the lazy_static dependency for a couple reasons.
First, tests sharing global state should be a last resort which caught
my eye first. But then I also realized, there's actually a subtle test
we can add here per test. If core ever creates a non-writable file that
breaks directory removal, we wouldn't know which test it was using
lazy_static (as the error would happen at process exit). Creating a
TempDir per test means we'll automatically know which test caused the
issue (if it ever even happens).
  • Loading branch information
davisp committed Mar 18, 2024
1 parent 2dbf2f7 commit 2463e7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
lazy_static = "1.4.0"
tempdir = "0.3.7"
tiledb-sys = {version = "0.1.0", path = "tiledb-sys" }

[dev-dependencies]
tempdir = "0.3.7"
22 changes: 11 additions & 11 deletions src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,17 @@ impl Drop for Array<'_> {

#[cfg(test)]
mod tests {
extern crate lazy_static;
extern crate tempdir;
use std::io;
use tempdir::TempDir;

use crate::array::*;
use crate::context::Context;
use crate::Datatype;
use lazy_static::lazy_static;

lazy_static! {
static ref DIR: tempdir::TempDir =
tempdir::TempDir::new("tiledb-rs.array").unwrap();
}

#[test]
fn test_array_create() {
let arr_path = DIR.path().join("test_array_create");
fn test_array_create() -> io::Result<()> {
let tmp_dir = TempDir::new("test_rs_bdelit")?;
let arr_dir = tmp_dir.path().join("create_test");

let c: Context = Context::new().unwrap();

Expand Down Expand Up @@ -196,6 +191,11 @@ mod tests {

// domain not set
// TODO
assert!(Array::create(&c, arr_path.to_str().unwrap(), s).is_ok());
assert!(Array::create(&c, arr_dir.to_str().unwrap(), s).is_ok());

// Make sure we can remove the array we created.
tmp_dir.close()?;

Ok(())
}
}

0 comments on commit 2463e7a

Please sign in to comment.