deps: update tempfile to 3 #900
Conversation
I'm not sure if you want to have prefixed directories, but kept it as it was. |
(except for the doctest for simplicity sake) |
Overall, it looks good. But I think we should be consistent about using either anonymous or named temporary files/directories. The preference should probably be anonymous tempfile > named tempfile > anonymous tempdir > named tempdir. |
|
||
let tempdir = TempDir::new("test_getsockname").unwrap(); | ||
let tempdir = tempfile::Builder::new() |
asomers
May 11, 2018
Member
Shouldn't this test work even with an anonymous tempdir, like this? I think anonymous tempdirs still have names; only anonymous tempfiles don't.
let tempdir = TempDir::new();
let sockname = tempdir.path().join("sock")
Shouldn't this test work even with an anonymous tempdir, like this? I think anonymous tempdirs still have names; only anonymous tempfiles don't.
let tempdir = TempDir::new();
let sockname = tempdir.path().join("sock")
ignatenkobrain
May 11, 2018
Author
Contributor
it should, just wanted to keep prefixes as it was in original code. If this is not needed, I'm going to drop it.
it should, just wanted to keep prefixes as it was in original code. If this is not needed, I'm going to drop it.
@@ -114,7 +113,10 @@ fn test_pwrite() { | |||
fn test_pread() { | |||
use std::io::Write; | |||
|
|||
let tempdir = TempDir::new("nix-test_pread").unwrap(); |
asomers
May 11, 2018
Member
In this case, I think you can use an anonymous temp file like this. Less code, and no Rust cleanup required. test_pwrite
already does just this.
let mut file = tempfile().unwrap();
In this case, I think you can use an anonymous temp file like this. Less code, and no Rust cleanup required. test_pwrite
already does just this.
let mut file = tempfile().unwrap();
@ignatenkobrain friendly ping |
sorry for delay, was busy with $dayjob. Updating now. |
rebased + updated. |
Looks like you have a basic syntax error. Did you test locally before pushing? |
@asomers passes now |
I'd agree with consistently using anonymous directories. I'd also suggest we be consistent with using |
@Susurrus does that mean you don't approve? If so, please give a negative review to indicate that the PR still needs some work. |
We should have consistent usages of |
@@ -30,7 +29,9 @@ fn test_openat() { | |||
|
|||
#[test] | |||
fn test_readlink() { | |||
let tempdir = TempDir::new("nix-test_readdir") | |||
let tempdir = tempfile::Builder::new() |
Susurrus
Jul 15, 2018
Contributor
Just tempfile::tempdir().unwrap();
should be fine.
Just tempfile::tempdir().unwrap();
should be fine.
@@ -32,7 +32,9 @@ exit 23"; | |||
|
|||
const NONE: Option<&'static [u8]> = None; | |||
pub fn test_mount_tmpfs_without_flags_allows_rwx() { | |||
let tempdir = TempDir::new("nix-test_mount") | |||
let tempdir = tempfile::Builder::new() |
Susurrus
Jul 15, 2018
Contributor
Just tempfile::tempdir().unwrap();
should be fine.
Just tempfile::tempdir().unwrap();
should be fine.
@@ -89,7 +91,9 @@ exit 23"; | |||
} | |||
|
|||
pub fn test_mount_rdonly_disallows_write() { | |||
let tempdir = TempDir::new("nix-test_mount") | |||
let tempdir = tempfile::Builder::new() |
Susurrus
Jul 15, 2018
Contributor
Just tempfile::tempdir().unwrap();
should be fine.
Just tempfile::tempdir().unwrap();
should be fine.
@@ -107,7 +111,9 @@ exit 23"; | |||
} | |||
|
|||
pub fn test_mount_noexec_disallows_exec() { | |||
let tempdir = TempDir::new("nix-test_mount") | |||
let tempdir = tempfile::Builder::new() |
Susurrus
Jul 15, 2018
Contributor
Just tempfile::tempdir().unwrap();
should be fine.
Just tempfile::tempdir().unwrap();
should be fine.
@@ -146,12 +152,16 @@ exit 23"; | |||
} | |||
|
|||
pub fn test_mount_bind() { | |||
let tempdir = TempDir::new("nix-test_mount") | |||
let tempdir = tempfile::Builder::new() |
Susurrus
Jul 15, 2018
Contributor
Just tempfile::tempdir().unwrap();
should be fine.
Just tempfile::tempdir().unwrap();
should be fine.
@@ -106,7 +115,10 @@ fn test_stat_fstat_lstat() { | |||
|
|||
#[test] | |||
fn test_fchmod() { | |||
let tempdir = TempDir::new("nix-test_fchmod").unwrap(); | |||
let tempdir = tempfile::Builder::new() |
Susurrus
Jul 15, 2018
Contributor
Just tempfile::tempdir().unwrap();
should be fine.
Just tempfile::tempdir().unwrap();
should be fine.
@@ -128,7 +140,10 @@ fn test_fchmod() { | |||
|
|||
#[test] | |||
fn test_fchmodat() { | |||
let tempdir = TempDir::new("nix-test_fchmodat").unwrap(); | |||
let tempdir = tempfile::Builder::new() |
Susurrus
Jul 15, 2018
Contributor
Just tempfile::tempdir().unwrap();
should be fine.
Just tempfile::tempdir().unwrap();
should be fine.
@@ -84,7 +81,10 @@ fn test_mkstemp_directory() { | |||
|
|||
#[test] | |||
fn test_mkfifo() { | |||
let tempdir = TempDir::new("nix-test_mkfifo").unwrap(); | |||
let tempdir = tempfile::Builder::new() |
Susurrus
Jul 15, 2018
Contributor
Just tempfile::tempdir().unwrap();
should be fine.
Just tempfile::tempdir().unwrap();
should be fine.
@@ -286,7 +286,10 @@ fn test_fchdir() { | |||
#[allow(unused_variables)] | |||
let m = ::CWD_MTX.lock().expect("Mutex got poisoned by another test"); | |||
|
|||
let tmpdir = TempDir::new("test_fchdir").unwrap(); | |||
let tmpdir = tempfile::Builder::new() |
Susurrus
Jul 15, 2018
Contributor
Just tempfile::tempdir().unwrap();
should be fine.
Just tempfile::tempdir().unwrap();
should be fine.
@@ -302,7 +305,10 @@ fn test_getcwd() { | |||
#[allow(unused_variables)] | |||
let m = ::CWD_MTX.lock().expect("Mutex got poisoned by another test"); | |||
|
|||
let tmpdir = TempDir::new("test_getcwd").unwrap(); | |||
let tmpdir = tempfile::Builder::new() |
Susurrus
Jul 15, 2018
Contributor
Just tempfile::tempdir().unwrap();
should be fine.
Just tempfile::tempdir().unwrap();
should be fine.
fd85572
to
9e1caa4
Updated to address all points from @Susurrus |
Test failures on i386 freebsd 11. Travis reported a spurious failure I'm rerunning. |
@@ -90,9 +90,9 @@ pub fn test_abstract_uds_addr() { | |||
pub fn test_getsockname() { | |||
use nix::sys::socket::{socket, AddressFamily, SockType, SockFlag}; | |||
use nix::sys::socket::{bind, SockAddr}; | |||
use tempdir::TempDir; | |||
use tempfile; |
Susurrus
Jul 24, 2018
Contributor
This isn't necessary, correct?
This isn't necessary, correct?
Susurrus
Aug 10, 2018
Contributor
Sorry, don't know what I was talking about here. But since none of these are conditionally compiled I'd suggest we put a single use
statement at the top of the file and get rid of all of the additional ones.
Sorry, don't know what I was talking about here. But since none of these are conditionally compiled I'd suggest we put a single use
statement at the top of the file and get rid of all of the additional ones.
It seems like
Is it possible to bump the required rust version for nix to 1.22 or higher? I'm also interested in having this in for #930 |
There's nothing special about 1.20.0. You can bump the minimum compiler version if it's for a good reason. |
Correct. I have to update the buildbots outside of Github. I'll do that after you settle on a Rustc version. Will it be 1.22.0 or 1.24.1? |
These changes all look good to me. Just needs the version stuff sorted out. I will say that I'd like to bump the version as little as possible. If 1.22.0 works, I'd prefer we use that. |
I believe the buildbots have been updated to 1.22.1, @ignatenkobrain will you have time to work on this in the near future? We'd like to get this merged before some other PRs. |
b8e8454
to
6ccfc37
we should be all good. |
As a general remark, I would try to use |
/// | ||
/// fn main() { | ||
/// let tmp_dir1 = TempDir::new("test_mkdir").unwrap(); | ||
/// let tmp_dir1 = TempDir::new().unwrap(); |
bachp
Aug 15, 2018
Contributor
use tempfile::tempdir().unwrap()
here
use tempfile::tempdir().unwrap()
here
/// extern crate nix; | ||
/// | ||
/// use nix::unistd; | ||
/// use nix::sys::stat; | ||
/// use tempdir::TempDir; | ||
/// use tempfile::TempDir; |
bachp
Aug 15, 2018
Contributor
only use tempfile
or tempfile::tempdir
so it can be uses as tempdir().unwrap()
only use tempfile
or tempfile::tempdir
so it can be uses as tempdir().unwrap()
/// | ||
/// fn main() { | ||
/// let tmp_dir = TempDir::new("test_fifo").unwrap(); | ||
/// let tmp_dir = TempDir::new().unwrap(); |
bachp
Aug 15, 2018
Contributor
use tempfile::tempdir().unwrap()
here, same as above
use tempfile::tempdir().unwrap()
here, same as above
@@ -5,8 +5,7 @@ use std::{cmp, iter}; | |||
use std::fs::{OpenOptions}; | |||
use std::os::unix::io::AsRawFd; | |||
|
|||
use tempdir::TempDir; | |||
use tempfile::tempfile; | |||
use tempfile::{self, tempfile}; |
bachp
Aug 15, 2018
Contributor
use tempfile::{tempdir, tempfile}
no need to import self
use tempfile::{tempdir, tempfile}
no need to import self
@@ -114,7 +113,7 @@ fn test_pwrite() { | |||
fn test_pread() { | |||
use std::io::Write; | |||
|
|||
let tempdir = TempDir::new("nix-test_pread").unwrap(); | |||
let tempdir = tempfile::tempdir().unwrap(); |
bachp
Aug 15, 2018
Contributor
With use tempfile::{tempdir, tempfile}
this becomes just tempdir()
With use tempfile::{tempdir, tempfile}
this becomes just tempdir()
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
@bachp fixed. |
Looks good, but needs a CHANGELOG entry under the CHANGED entry with "Increased required Rust version to 1.22.1". Should also update the required version listed in the README. Please do these changes in the last commit. Then LGTM. @asomers anything on your end? |
No, I agree with you, @Susurrus . Just needs a CHANGELOG entry. |
@ignatenkobrain Would you be able to update the CHANGELOG and README and squash that into your last commit? This is otherwise ready to merge. |
Pinging you on this @ignatenkobrain. |
on it. |
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
done |
bors r+ |
Signed-off-by: Igor Gnatenko i.gnatenko.brain@gmail.com