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

refactor(global): Move from tempdir to tempfile: #1523

Merged
merged 1 commit into from
Jun 9, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 10 additions & 35 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ filetime = "0.2"
libc = "0.2"
rand = "0.6"
regex = "1.0"
tempdir = "0.3"
tempfile = "3.1"
time = "0.1"
unindent = "0.1"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="master", features=["entries"] }
Expand Down
2 changes: 1 addition & 1 deletion src/uu/stdbuf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ path = "src/stdbuf.rs"

[dependencies]
getopts = "0.2.18"
tempdir = "0.3.7"
tempfile = "3.1"
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }

Expand Down
7 changes: 4 additions & 3 deletions src/uu/stdbuf/src/stdbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// spell-checker:ignore (ToDO) tempdir dyld dylib dragonflybsd optgrps libstdbuf

extern crate getopts;
extern crate tempdir;
extern crate tempfile;

#[macro_use]
extern crate uucore;
Expand All @@ -19,7 +19,8 @@ use std::io::{self, Write};
use std::os::unix::process::ExitStatusExt;
use std::path::PathBuf;
use std::process::Command;
use tempdir::TempDir;
use tempfile::tempdir;
use tempfile::TempDir;

static NAME: &str = "stdbuf";
static VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -273,7 +274,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
let command_name = &args[command_idx as usize];
let mut command = Command::new(command_name);

let mut tmp_dir = return_if_err!(1, TempDir::new("stdbuf"));
let mut tmp_dir = tempdir().unwrap();
let (preload_env, libstdbuf) = return_if_err!(1, get_preload_env(&mut tmp_dir));
command
.args(&args[(command_idx as usize) + 1..])
Expand Down
2 changes: 1 addition & 1 deletion tests/by-util/test_cat.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern crate tempdir;
extern crate tempfile;
#[cfg(unix)]
extern crate unix_socket;

Expand Down
11 changes: 6 additions & 5 deletions tests/by-util/test_mktemp.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::common::util::*;
extern crate tempdir;
use self::tempdir::TempDir;

extern crate tempfile;
use self::tempfile::tempdir;

static TEST_TEMPLATE1: &'static str = "tempXXXXXX";
static TEST_TEMPLATE2: &'static str = "temp";
Expand Down Expand Up @@ -266,9 +267,9 @@ fn test_mktemp_suffix() {
#[test]
fn test_mktemp_tmpdir() {
let scene = TestScenario::new(util_name!());

let path = TempDir::new_in(scene.fixtures.as_string(), util_name!()).unwrap();
let pathname = path.path().as_os_str();
let dir = tempdir().unwrap();
let path = dir.path().join(scene.fixtures.as_string());
let pathname = path.as_os_str();

scene
.ucmd()
Expand Down
6 changes: 3 additions & 3 deletions tests/common/util.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(dead_code)]
extern crate tempdir;
extern crate tempfile;

use self::tempdir::TempDir;
use self::tempfile::TempDir;
use std::env;
use std::ffi::OsStr;
use std::fs::{self, File, OpenOptions};
Expand Down Expand Up @@ -406,7 +406,7 @@ pub struct TestScenario {

impl TestScenario {
pub fn new(util_name: &str) -> TestScenario {
let tmpd = Rc::new(TempDir::new("uutils").unwrap());
let tmpd = Rc::new(TempDir::new().unwrap());
let ts = TestScenario {
bin_path: {
// Instead of hardcoding the path relative to the current
Expand Down