Skip to content

Commit 8daf81e

Browse files
committed
Replace tempdir by tempfile
The former has been deprecated in favor of the latter
1 parent 311a5ed commit 8daf81e

File tree

7 files changed

+15
-13
lines changed

7 files changed

+15
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ serde_ignored = "0.0.4"
4848
serde_json = "1.0"
4949
shell-escape = "0.1"
5050
tar = { version = "0.4", default-features = false }
51-
tempdir = "0.3"
51+
tempfile = "3.0"
5252
termcolor = "0.3"
5353
toml = "0.4"
5454
url = "1.1"

src/cargo/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern crate serde_ignored;
4040
extern crate serde_json;
4141
extern crate shell_escape;
4242
extern crate tar;
43-
extern crate tempdir;
43+
extern crate tempfile;
4444
extern crate termcolor;
4545
extern crate toml;
4646
extern crate url;

src/cargo/ops/cargo_install.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
77
use std::sync::Arc;
88

99
use semver::{Version, VersionReq};
10-
use tempdir::TempDir;
10+
use tempfile::Builder as TempFileBuilder;
1111
use toml;
1212

1313
use core::{Dependency, Package, PackageIdSpec, Source, SourceId};
@@ -210,7 +210,7 @@ fn install_one(
210210
None
211211
} else if let Some(dir) = config.target_dir()? {
212212
Some(dir)
213-
} else if let Ok(td) = TempDir::new("cargo-install") {
213+
} else if let Ok(td) = TempFileBuilder::new().prefix("cargo-install").tempdir() {
214214
let p = td.path().to_owned();
215215
td_opt = Some(td);
216216
Some(Filesystem::new(p))
@@ -284,7 +284,9 @@ fn install_one(
284284
// Copy all binaries to a temporary directory under `dst` first, catching
285285
// some failure modes (e.g. out of space) before touching the existing
286286
// binaries. This directory will get cleaned up via RAII.
287-
let staging_dir = TempDir::new_in(&dst, "cargo-install")?;
287+
let staging_dir = TempFileBuilder::new()
288+
.prefix("cargo-install")
289+
.tempdir_in(&dst)?;
288290
for &(bin, src) in binaries.iter() {
289291
let dst = staging_dir.path().join(bin);
290292
// Try to move if `target_dir` is transient.

tests/testsuite/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use cargotest::support::{basic_bin_manifest, execs, main_file, project};
1111
use cargotest::support::registry::Package;
1212
use cargotest::ChannelChanger;
1313
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
14-
use tempdir::TempDir;
14+
use tempfile;
1515

1616
#[test]
1717
fn cargo_compile_simple() {
@@ -546,7 +546,7 @@ Caused by:
546546

547547
#[test]
548548
fn cargo_compile_without_manifest() {
549-
let tmpdir = TempDir::new("cargo").unwrap();
549+
let tmpdir = tempfile::Builder::new().prefix("cargo").tempdir().unwrap();
550550
let p = ProjectBuilder::new("foo", tmpdir.path().to_path_buf()).build();
551551

552552
assert_that(

tests/testsuite/init.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::env;
66
use cargo::util::ProcessBuilder;
77
use cargotest::support::{cargo_exe, execs, paths};
88
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
9-
use tempdir::TempDir;
9+
use tempfile;
1010

1111
fn cargo_process(s: &str) -> ProcessBuilder {
1212
let mut p = cargotest::process(&cargo_exe());
@@ -62,7 +62,7 @@ fn simple_bin() {
6262

6363
#[test]
6464
fn both_lib_and_bin() {
65-
let td = TempDir::new("cargo").unwrap();
65+
let td = tempfile::Builder::new().prefix("cargo").tempdir().unwrap();
6666
assert_that(
6767
cargo_process("init")
6868
.arg("--lib")
@@ -328,7 +328,7 @@ fn simple_git() {
328328

329329
#[test]
330330
fn auto_git() {
331-
let td = TempDir::new("cargo").unwrap();
331+
let td = tempfile::Builder::new().prefix("cargo").tempdir().unwrap();
332332
let foo = &td.path().join("foo");
333333
fs::create_dir_all(&foo).unwrap();
334334
assert_that(

tests/testsuite/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern crate serde_derive;
1313
#[macro_use]
1414
extern crate serde_json;
1515
extern crate tar;
16-
extern crate tempdir;
16+
extern crate tempfile;
1717
extern crate toml;
1818
extern crate url;
1919
#[cfg(windows)]

tests/testsuite/new.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cargo::util::ProcessBuilder;
77
use cargotest::process;
88
use cargotest::support::{execs, paths};
99
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
10-
use tempdir::TempDir;
10+
use tempfile;
1111

1212
fn cargo_process(s: &str) -> ProcessBuilder {
1313
let mut p = cargotest::cargo_process();
@@ -113,7 +113,7 @@ fn simple_git() {
113113
// Run inside a temp directory so that cargo will initialize a git repo.
114114
// If this ran inside paths::root() it would detect that we are already
115115
// inside a git repo and skip the initialization.
116-
let td = TempDir::new("cargo").unwrap();
116+
let td = tempfile::Builder::new().prefix("cargo").tempdir().unwrap();
117117
assert_that(
118118
cargo_process("new")
119119
.arg("--lib")

0 commit comments

Comments
 (0)