Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update tempfile to 3 #900

Merged
merged 3 commits into from Sep 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
50 changes: 25 additions & 25 deletions .travis.yml
Expand Up @@ -22,63 +22,63 @@ matrix:
# Additionally they're moved to the front of the line to get them in the Travis
# OS X build queue first.
- env: TARGET="aarch64-apple-ios;armv7-apple-ios;armv7s-apple-ios;i386-apple-ios;x86_64-apple-ios" DISABLE_TESTS=1
rust: 1.20.0
rust: 1.22.1
os: osx

# Mac builds
# These are also moved to be first because they wait in a long queue with Travis
- env: TARGET=i686-apple-darwin
rust: 1.20.0
rust: 1.22.1
os: osx
- env: TARGET=x86_64-apple-darwin
rust: 1.20.0
rust: 1.22.1
os: osx

# Android
- env: TARGET=aarch64-linux-android DISABLE_TESTS=1
rust: 1.20.0
rust: 1.22.1
- env: TARGET=arm-linux-androideabi DISABLE_TESTS=1
rust: 1.20.0
rust: 1.22.1
- env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1
rust: 1.20.0
rust: 1.22.1
- env: TARGET=i686-linux-android DISABLE_TESTS=1
rust: 1.20.0
rust: 1.22.1
- env: TARGET=x86_64-linux-android DISABLE_TESTS=1
rust: 1.20.0
rust: 1.22.1

# Linux
- env: TARGET=aarch64-unknown-linux-gnu
rust: 1.20.0
rust: 1.22.1
- env: TARGET=arm-unknown-linux-gnueabi
rust: 1.20.0
rust: 1.22.1
- env: TARGET=arm-unknown-linux-musleabi DISABLE_TESTS=1
rust: 1.20.0
rust: 1.22.1
- env: TARGET=armv7-unknown-linux-gnueabihf
rust: 1.20.0
rust: 1.22.1
- env: TARGET=i686-unknown-linux-gnu
rust: 1.20.0
rust: 1.22.1
- env: TARGET=i686-unknown-linux-musl
rust: 1.20.0
rust: 1.22.1
- env: TARGET=mips-unknown-linux-gnu
rust: 1.20.0
rust: 1.22.1
- env: TARGET=mips64-unknown-linux-gnuabi64
rust: 1.20.0
rust: 1.22.1
- env: TARGET=mips64el-unknown-linux-gnuabi64
rust: 1.20.0
rust: 1.22.1
- env: TARGET=mipsel-unknown-linux-gnu
rust: 1.20.0
rust: 1.22.1
- env: TARGET=powerpc-unknown-linux-gnu DISABLE_TESTS=1
rust: 1.20.0
rust: 1.22.1
- env: TARGET=powerpc64-unknown-linux-gnu
rust: 1.20.0
rust: 1.22.1
- env: TARGET=powerpc64le-unknown-linux-gnu
rust: 1.20.0
rust: 1.22.1
- env: TARGET=s390x-unknown-linux-gnu DISABLE_TESTS=1
rust: 1.20.0
rust: 1.22.1
- env: TARGET=x86_64-unknown-linux-gnu
rust: 1.20.0
rust: 1.22.1
- env: TARGET=x86_64-unknown-linux-musl
rust: 1.20.0
rust: 1.22.1

# *BSD
# FreeBSD i686 and x86_64 use BuildBot instead of Travis
Expand All @@ -87,7 +87,7 @@ matrix:
# - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1
# - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
- env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1
rust: 1.20.0
rust: 1.22.1

# Make sure stable is always working too
- env: TARGET=x86_64-unknown-linux-gnu
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
([#923](https://github.com/nix-rust/nix/pull/923))

### Changed
- Increased required Rust version to 1.22.1/
([#900](https://github.com/nix-rust/nix/pull/900))

### Fixed
- Made `preadv` take immutable slice of IoVec.
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Expand Up @@ -24,8 +24,7 @@ cc = "1"
bytes = "0.4.8"
lazy_static = "1"
rand = "0.4"
tempdir = "0.3"
tempfile = "2"
tempfile = "3"

[target.'cfg(target_os = "freebsd")'.dev-dependencies]
sysctl = "0.1"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -44,7 +44,7 @@ limitations. Support for platforms is split into three tiers:
*do not* block the inclusion of new code. Testing may be run, but
failures in tests don't block the inclusion of new code.

The following targets are all supported by nix on Rust 1.20.0 or newer (unless
The following targets are all supported by nix on Rust 1.22.1 or newer (unless
otherwise noted):

Tier 1:
Expand Down
2 changes: 1 addition & 1 deletion src/sys/socket/mod.rs
Expand Up @@ -678,7 +678,7 @@ pub fn sendmsg<'a>(fd: RawFd, iov: &[IoVec<&'a [u8]>], cmsgs: &[ControlMessage<'
{
let mut ofs = 0;
for cmsg in cmsgs {
let mut ptr = &mut cmsg_buffer[ofs..];
let ptr = &mut cmsg_buffer[ofs..];
unsafe {
cmsg.encode_into(ptr);
}
Expand Down
12 changes: 6 additions & 6 deletions src/unistd.rs
Expand Up @@ -436,15 +436,15 @@ pub fn fchdir(dirfd: RawFd) -> Result<()> {
/// # Example
///
/// ```rust
/// extern crate tempdir;
/// extern crate tempfile;
/// extern crate nix;
///
/// use nix::unistd;
/// use nix::sys::stat;
/// use tempdir::TempDir;
/// use tempfile::tempdir;
///
/// fn main() {
/// let tmp_dir1 = TempDir::new("test_mkdir").unwrap();
/// let tmp_dir1 = tempdir().unwrap();
/// let tmp_dir2 = tmp_dir1.path().join("new_dir");
///
/// // create new directory and give read, write and execute rights to the owner
Expand Down Expand Up @@ -479,15 +479,15 @@ pub fn mkdir<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()> {
/// # Example
///
/// ```rust
/// extern crate tempdir;
/// extern crate tempfile;
/// extern crate nix;
///
/// use nix::unistd;
/// use nix::sys::stat;
/// use tempdir::TempDir;
/// use tempfile::tempdir;
///
/// fn main() {
/// let tmp_dir = TempDir::new("test_fifo").unwrap();
/// let tmp_dir = tempdir().unwrap();
/// let fifo_path = tmp_dir.path().join("foo.pipe");
///
/// // create new fifo and give read, write and execute rights to the owner
Expand Down
7 changes: 3 additions & 4 deletions test/sys/test_socket.rs
Expand Up @@ -5,6 +5,7 @@ use std::path::Path;
use std::str::FromStr;
use std::os::unix::io::RawFd;
use libc::c_char;
use tempfile;

#[test]
pub fn test_inetv4_addr_to_sock_addr() {
Expand Down Expand Up @@ -90,9 +91,8 @@ 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;

let tempdir = TempDir::new("test_getsockname").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let sockname = tempdir.path().join("sock");
let sock = socket(AddressFamily::Unix, SockType::Stream, SockFlag::empty(), None)
.expect("socket failed");
Expand Down Expand Up @@ -406,9 +406,8 @@ pub fn test_unixdomain() {
use nix::sys::socket::{bind, socket, connect, listen, accept, SockAddr};
use nix::unistd::{read, write, close};
use std::thread;
use tempdir::TempDir;

let tempdir = TempDir::new("test_unixdomain").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let sockname = tempdir.path().join("sock");
let s1 = socket(AddressFamily::Unix, SockType::Stream,
SockFlag::empty(), None).expect("socket failed");
Expand Down
9 changes: 4 additions & 5 deletions test/sys/test_uio.rs
Expand Up @@ -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::{tempfile, tempdir};

#[test]
fn test_writev() {
Expand Down Expand Up @@ -114,7 +113,7 @@ fn test_pwrite() {
fn test_pread() {
use std::io::Write;

let tempdir = TempDir::new("nix-test_pread").unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

let tempdir = tempdir().unwrap();

let path = tempdir.path().join("pread_test_file");
let mut file = OpenOptions::new().write(true).read(true).create(true)
Expand Down Expand Up @@ -142,7 +141,7 @@ fn test_pwritev() {
IoVec::from_slice(&to_write[64..128]),
];

let tempdir = TempDir::new("nix-test_pwritev").unwrap();
let tempdir = tempdir().unwrap();

// pwritev them into a temporary file
let path = tempdir.path().join("pwritev_test_file");
Expand All @@ -166,7 +165,7 @@ fn test_preadv() {
let to_write: Vec<u8> = (0..200).collect();
let expected: Vec<u8> = (100..200).collect();

let tempdir = TempDir::new("nix-test_preadv").unwrap();
let tempdir = tempdir().unwrap();

let path = tempdir.path().join("preadv_test_file");

Expand Down
1 change: 0 additions & 1 deletion test/test.rs
Expand Up @@ -7,7 +7,6 @@ extern crate nix;
extern crate lazy_static;
extern crate libc;
extern crate rand;
extern crate tempdir;
extern crate tempfile;

mod sys;
Expand Down
6 changes: 2 additions & 4 deletions test/test_fcntl.rs
@@ -1,8 +1,7 @@
use nix::fcntl::{openat, open, OFlag, readlink, readlinkat};
use nix::sys::stat::Mode;
use nix::unistd::{close, read};
use tempdir::TempDir;
use tempfile::NamedTempFile;
use tempfile::{self, NamedTempFile};
use std::io::prelude::*;
use std::os::unix::fs;

Expand Down Expand Up @@ -30,8 +29,7 @@ fn test_openat() {

#[test]
fn test_readlink() {
let tempdir = TempDir::new("nix-test_readdir")
.unwrap_or_else(|e| panic!("tempdir failed: {}", e));
let tempdir = tempfile::tempdir().unwrap();
let src = tempdir.path().join("a");
let dst = tempdir.path().join("b");
println!("a: {:?}, b: {:?}", &src, &dst);
Expand Down
19 changes: 7 additions & 12 deletions test/test_mount.rs
Expand Up @@ -5,7 +5,7 @@

extern crate libc;
extern crate nix;
extern crate tempdir;
extern crate tempfile;

#[cfg(target_os = "linux")]
mod test_mount {
Expand All @@ -23,7 +23,7 @@ mod test_mount {
use nix::sys::stat::{self, Mode};
use nix::unistd::getuid;

use tempdir::TempDir;
use tempfile;

static SCRIPT_CONTENTS: &'static [u8] = b"#!/bin/sh
exit 23";
Expand All @@ -32,8 +32,7 @@ exit 23";

const NONE: Option<&'static [u8]> = None;
pub fn test_mount_tmpfs_without_flags_allows_rwx() {
let tempdir = TempDir::new("nix-test_mount")
.unwrap_or_else(|e| panic!("tempdir failed: {}", e));
let tempdir = tempfile::tempdir().unwrap();

mount(NONE,
tempdir.path(),
Expand Down Expand Up @@ -89,8 +88,7 @@ exit 23";
}

pub fn test_mount_rdonly_disallows_write() {
let tempdir = TempDir::new("nix-test_mount")
.unwrap_or_else(|e| panic!("tempdir failed: {}", e));
let tempdir = tempfile::tempdir().unwrap();

mount(NONE,
tempdir.path(),
Expand All @@ -107,8 +105,7 @@ exit 23";
}

pub fn test_mount_noexec_disallows_exec() {
let tempdir = TempDir::new("nix-test_mount")
.unwrap_or_else(|e| panic!("tempdir failed: {}", e));
let tempdir = tempfile::tempdir().unwrap();

mount(NONE,
tempdir.path(),
Expand Down Expand Up @@ -146,13 +143,11 @@ exit 23";
}

pub fn test_mount_bind() {
let tempdir = TempDir::new("nix-test_mount")
.unwrap_or_else(|e| panic!("tempdir failed: {}", e));
let tempdir = tempfile::tempdir().unwrap();
let file_name = "test";

{
let mount_point = TempDir::new("nix-test_mount")
.unwrap_or_else(|e| panic!("tempdir failed: {}", e));
let mount_point = tempfile::tempdir().unwrap();

mount(Some(tempdir.path()),
mount_point.path(),
Expand Down
12 changes: 6 additions & 6 deletions test/test_stat.rs
Expand Up @@ -9,7 +9,7 @@ use nix::sys::stat::{self, fchmod, fchmodat, fstat, lstat, stat};
use nix::sys::stat::{FileStat, Mode, FchmodatFlags};
use nix::unistd::chdir;
use nix::Result;
use tempdir::TempDir;
use tempfile;

#[allow(unused_comparisons)]
// uid and gid are signed on Windows, but not on other platforms. This function
Expand Down Expand Up @@ -56,7 +56,7 @@ fn assert_lstat_results(stat_result: Result<FileStat>) {

#[test]
fn test_stat_and_fstat() {
let tempdir = TempDir::new("nix-test_stat_and_fstat").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let filename = tempdir.path().join("foo.txt");
let file = File::create(&filename).unwrap();

Expand All @@ -69,7 +69,7 @@ fn test_stat_and_fstat() {

#[test]
fn test_fstatat() {
let tempdir = TempDir::new("nix-test_fstatat").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let filename = tempdir.path().join("foo.txt");
File::create(&filename).unwrap();
let dirfd = fcntl::open(tempdir.path(),
Expand All @@ -84,7 +84,7 @@ fn test_fstatat() {

#[test]
fn test_stat_fstat_lstat() {
let tempdir = TempDir::new("nix-test_stat_fstat_lstat").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let filename = tempdir.path().join("bar.txt");
let linkname = tempdir.path().join("barlink");

Expand All @@ -106,7 +106,7 @@ fn test_stat_fstat_lstat() {

#[test]
fn test_fchmod() {
let tempdir = TempDir::new("nix-test_fchmod").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let filename = tempdir.path().join("foo.txt");
let file = File::create(&filename).unwrap();

Expand All @@ -128,7 +128,7 @@ fn test_fchmod() {

#[test]
fn test_fchmodat() {
let tempdir = TempDir::new("nix-test_fchmodat").unwrap();
let tempdir = tempfile::tempdir().unwrap();
let filename = "foo.txt";
let fullpath = tempdir.path().join(filename);
File::create(&fullpath).unwrap();
Expand Down