Skip to content

Commit 25197cf

Browse files
committed
refactor(global): Move from tempdir to tempfile:
* the crate has been deprecated
1 parent 272b66a commit 25197cf

File tree

7 files changed

+161
-91
lines changed

7 files changed

+161
-91
lines changed

Cargo.lock

+145-77
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
@@ -319,7 +319,7 @@ lazy_static = "1.3"
319319
libc = "0.2"
320320
rand = "0.6"
321321
regex = "1.0"
322-
tempdir = "0.3"
322+
tempfile = "3.1"
323323
time = "0.1"
324324
unindent = "0.1"
325325

src/uu/stdbuf/Cargo.toml

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

1212
[dependencies]
1313
getopts = "0.2.18"
14-
tempdir = "0.3.7"
14+
tempfile = "3.1"
1515
uucore = "0.0.2"
1616

1717
[build-dependencies]

src/uu/stdbuf/src/stdbuf.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
extern crate getopts;
13-
extern crate tempdir;
13+
extern crate tempfile;
1414

1515
#[macro_use]
1616
extern crate uucore;
@@ -21,7 +21,8 @@ use std::io::{self, Write};
2121
use std::os::unix::process::ExitStatusExt;
2222
use std::path::PathBuf;
2323
use std::process::Command;
24-
use tempdir::TempDir;
24+
use tempfile::tempdir;
25+
use tempfile::TempDir;
2526

2627
static NAME: &str = "stdbuf";
2728
static VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -275,7 +276,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
275276
let command_name = &args[command_idx as usize];
276277
let mut command = Command::new(command_name);
277278

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

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

tests/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/test_mktemp.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use 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()

0 commit comments

Comments
 (0)