Skip to content

Commit ac34d13

Browse files
committed
refactor(global): Move from tempdir to tempfile:
* the crate has been deprecated
1 parent 8098725 commit ac34d13

File tree

7 files changed

+26
-49
lines changed

7 files changed

+26
-49
lines changed

Cargo.lock

+10-35
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ filetime = "0.2"
332332
libc = "0.2"
333333
rand = "0.6"
334334
regex = "1.0"
335-
tempdir = "0.3"
335+
tempfile = "3.1"
336336
time = "0.1"
337337
unindent = "0.1"
338338
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="master", features=["entries"] }

src/uu/stdbuf/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ path = "src/stdbuf.rs"
1616

1717
[dependencies]
1818
getopts = "0.2.18"
19-
tempdir = "0.3.7"
19+
tempfile = "3.1"
2020
uucore = { version="0.0.4", package="uucore", git="https://github.com/uutils/uucore.git", branch="canary" }
2121
uucore_procs = { version="0.0.4", package="uucore_procs", git="https://github.com/uutils/uucore.git", branch="canary" }
2222

src/uu/stdbuf/src/stdbuf.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// spell-checker:ignore (ToDO) tempdir dyld dylib dragonflybsd optgrps libstdbuf
99

1010
extern crate getopts;
11-
extern crate tempdir;
11+
extern crate tempfile;
1212

1313
#[macro_use]
1414
extern crate uucore;
@@ -19,7 +19,8 @@ use std::io::{self, Write};
1919
use std::os::unix::process::ExitStatusExt;
2020
use std::path::PathBuf;
2121
use std::process::Command;
22-
use tempdir::TempDir;
22+
use tempfile::tempdir;
23+
use tempfile::TempDir;
2324

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

276-
let mut tmp_dir = return_if_err!(1, TempDir::new("stdbuf"));
277+
let mut tmp_dir = tempdir().unwrap();
277278
let (preload_env, libstdbuf) = return_if_err!(1, get_preload_env(&mut tmp_dir));
278279
command
279280
.args(&args[(command_idx as usize) + 1..])

tests/by-util/test_cat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extern crate tempdir;
1+
extern crate tempfile;
22
#[cfg(unix)]
33
extern crate unix_socket;
44

tests/by-util/test_mktemp.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::common::util::*;
2-
extern crate tempdir;
3-
use self::tempdir::TempDir;
2+
3+
extern crate tempfile;
4+
use self::tempfile::tempdir;
45

56
static TEST_TEMPLATE1: &'static str = "tempXXXXXX";
67
static TEST_TEMPLATE2: &'static str = "temp";
@@ -266,9 +267,9 @@ fn test_mktemp_suffix() {
266267
#[test]
267268
fn test_mktemp_tmpdir() {
268269
let scene = TestScenario::new(util_name!());
269-
270-
let path = TempDir::new_in(scene.fixtures.as_string(), util_name!()).unwrap();
271-
let pathname = path.path().as_os_str();
270+
let dir = tempdir().unwrap();
271+
let path = dir.path().join(scene.fixtures.as_string());
272+
let pathname = path.as_os_str();
272273

273274
scene
274275
.ucmd()

tests/common/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(dead_code)]
2-
extern crate tempdir;
2+
extern crate tempfile;
33

4-
use self::tempdir::TempDir;
4+
use self::tempfile::TempDir;
55
use std::env;
66
use std::ffi::OsStr;
77
use std::fs::{self, File, OpenOptions};
@@ -406,7 +406,7 @@ pub struct TestScenario {
406406

407407
impl TestScenario {
408408
pub fn new(util_name: &str) -> TestScenario {
409-
let tmpd = Rc::new(TempDir::new("uutils").unwrap());
409+
let tmpd = Rc::new(TempDir::new().unwrap());
410410
let ts = TestScenario {
411411
bin_path: {
412412
// Instead of hardcoding the path relative to the current

0 commit comments

Comments
 (0)