Skip to content
Browse files

Fixes broken tests on nightly

Caused by rust-lang/cargo#3368.
Now the method for determining path for DB tests is exact copy
from `cargo`.
  • Loading branch information...
vhbit committed Jan 5, 2017
1 parent 456f13e commit 25c1fdc71f3ee1099de4341cf165532f57f94dea
Showing with 18 additions and 2 deletions.
  1. +18 −2 src/
@@ -16,9 +16,25 @@ static TEST_ROOT_DIR: &'static str = "test-dbs";
static NEXT_ID: AtomicUsize = ATOMIC_USIZE_INIT;

fn global_root() -> PathBuf {
let mut path = env::current_exe().unwrap();
path.pop(); // chop off exe name
path.pop(); // chop off 'debug'

// If `cargo test` is run manually then our path looks like
// `target/debug/foo`, in which case our `path` is already pointing at
// `target`. If, however, `cargo test --target $target` is used then the
// output is `target/$target/debug/foo`, so our path is pointing at
// `target/$target`. Here we conditionally pop the `$target` name.
if path.file_name().and_then(|s| s.to_str()) != Some("target") {


fn next_path() -> PathBuf {
let out_dir = PathBuf::from(&env::var("OUT_DIR").unwrap());
let root_dir = out_dir.join(TEST_ROOT_DIR);
let root_dir = global_root();

INIT_DIR_ONCE.call_once(|| {
if let Ok(root_meta) = fs::metadata(root_dir.clone()) {

0 comments on commit 25c1fdc

Please sign in to comment.
You can’t perform that action at this time.