-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Replace std::env::temp_dir with tempdir in tests #8103
Conversation
It looks like @niklasad1 signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TempDir::new("")
needs to be assigned to a value. Otherwise it's dropped to early, and temp directory is never cleaned up
ethash/src/lib.rs
Outdated
let ethash = EthashManager::new(&::std::env::temp_dir(), None); | ||
use tempdir::TempDir; | ||
|
||
let ethash = EthashManager::new(TempDir::new("").unwrap().path(), None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't work as expected, cause TempDir
is dropped before EthashManager
, so the directory won't be cleaned up
ethcore/node_filter/src/lib.rs
Outdated
|
||
/// Contract code: https://gist.github.com/arkpar/467dbcc73cbb85b0997a7a10ffa0695f | ||
#[test] | ||
fn node_filter() { | ||
let contract_addr = Address::from_str("0000000000000000000000000000000000000005").unwrap(); | ||
let data = include_bytes!("../res/node_filter.json"); | ||
let spec = Spec::load(&::std::env::temp_dir(), &data[..]).unwrap(); | ||
let spec = Spec::load(&TempDir::new("").unwrap().path(), &data[..]).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, TempDir
will be dropped to early
ethash/src/compute.rs
Outdated
@@ -387,26 +388,26 @@ mod test { | |||
]; | |||
let nonce = 0xd7b3ac70a301a249; | |||
// difficulty = 0x085657254bd9u64; | |||
let light = NodeCacheBuilder::new(None).light(&::std::env::temp_dir(), 486382); | |||
let light = NodeCacheBuilder::new(None).light(TempDir::new("").unwrap().path(), 486382); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here ;)
Well, technically I think the first commit is fine because the Am I wrong? |
7a92291
to
08a9856
Compare
08a9856
to
5d7ebad
Compare
You are right when it comes to function calls, but in many places the path was used to initialize a structure (e.g. |
Attempt to close #6147
The remaining occurrences of
std::env::temp_dir()
are the following: