Replace std::env::temp_dir with tempdir in tests (#8103)

* std::env::temp_dir -> tempdir in test context

* fix lifetime issue so tempdir removes tmpfiles
This commit is contained in:
Niklas Adolfsson
2018-03-14 12:26:20 +01:00
committed by Marek Kotewicz
parent 7e948a088f
commit 23fc5517b5
15 changed files with 65 additions and 21 deletions

View File

@@ -204,11 +204,13 @@ mod tests {
use header::Header;
use spec::Spec;
use engines::Seal;
use tempdir::TempDir;
/// Create a new test chain spec with `BasicAuthority` consensus engine.
fn new_test_authority() -> Spec {
let bytes: &[u8] = include_bytes!("../../res/basic_authority.json");
Spec::load(&::std::env::temp_dir(), bytes).expect("invalid chain spec")
let tempdir = TempDir::new("").unwrap();
Spec::load(&tempdir.path(), bytes).expect("invalid chain spec")
}
#[test]