mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Auto merge of #5244 - Eijebong:tempfile, r=alexcrichton
Replace tempdir by tempfile The former has been deprecated in favor of the latter
This commit is contained in:
commit
cff944b58a
@ -48,7 +48,7 @@ serde_ignored = "0.0.4"
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
shell-escape = "0.1"
|
shell-escape = "0.1"
|
||||||
tar = { version = "0.4", default-features = false }
|
tar = { version = "0.4", default-features = false }
|
||||||
tempdir = "0.3"
|
tempfile = "3.0"
|
||||||
termcolor = "0.3"
|
termcolor = "0.3"
|
||||||
toml = "0.4"
|
toml = "0.4"
|
||||||
url = "1.1"
|
url = "1.1"
|
||||||
|
@ -40,7 +40,7 @@ extern crate serde_ignored;
|
|||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate shell_escape;
|
extern crate shell_escape;
|
||||||
extern crate tar;
|
extern crate tar;
|
||||||
extern crate tempdir;
|
extern crate tempfile;
|
||||||
extern crate termcolor;
|
extern crate termcolor;
|
||||||
extern crate toml;
|
extern crate toml;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
|
@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use semver::{Version, VersionReq};
|
use semver::{Version, VersionReq};
|
||||||
use tempdir::TempDir;
|
use tempfile::Builder as TempFileBuilder;
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
use core::{Dependency, Package, PackageIdSpec, Source, SourceId};
|
use core::{Dependency, Package, PackageIdSpec, Source, SourceId};
|
||||||
@ -210,7 +210,7 @@ fn install_one(
|
|||||||
None
|
None
|
||||||
} else if let Some(dir) = config.target_dir()? {
|
} else if let Some(dir) = config.target_dir()? {
|
||||||
Some(dir)
|
Some(dir)
|
||||||
} else if let Ok(td) = TempDir::new("cargo-install") {
|
} else if let Ok(td) = TempFileBuilder::new().prefix("cargo-install").tempdir() {
|
||||||
let p = td.path().to_owned();
|
let p = td.path().to_owned();
|
||||||
td_opt = Some(td);
|
td_opt = Some(td);
|
||||||
Some(Filesystem::new(p))
|
Some(Filesystem::new(p))
|
||||||
@ -284,7 +284,9 @@ fn install_one(
|
|||||||
// Copy all binaries to a temporary directory under `dst` first, catching
|
// Copy all binaries to a temporary directory under `dst` first, catching
|
||||||
// some failure modes (e.g. out of space) before touching the existing
|
// some failure modes (e.g. out of space) before touching the existing
|
||||||
// binaries. This directory will get cleaned up via RAII.
|
// binaries. This directory will get cleaned up via RAII.
|
||||||
let staging_dir = TempDir::new_in(&dst, "cargo-install")?;
|
let staging_dir = TempFileBuilder::new()
|
||||||
|
.prefix("cargo-install")
|
||||||
|
.tempdir_in(&dst)?;
|
||||||
for &(bin, src) in binaries.iter() {
|
for &(bin, src) in binaries.iter() {
|
||||||
let dst = staging_dir.path().join(bin);
|
let dst = staging_dir.path().join(bin);
|
||||||
// Try to move if `target_dir` is transient.
|
// Try to move if `target_dir` is transient.
|
||||||
|
@ -11,7 +11,7 @@ use cargotest::support::{basic_bin_manifest, execs, main_file, project};
|
|||||||
use cargotest::support::registry::Package;
|
use cargotest::support::registry::Package;
|
||||||
use cargotest::ChannelChanger;
|
use cargotest::ChannelChanger;
|
||||||
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||||
use tempdir::TempDir;
|
use tempfile;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cargo_compile_simple() {
|
fn cargo_compile_simple() {
|
||||||
@ -546,7 +546,7 @@ Caused by:
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cargo_compile_without_manifest() {
|
fn cargo_compile_without_manifest() {
|
||||||
let tmpdir = TempDir::new("cargo").unwrap();
|
let tmpdir = tempfile::Builder::new().prefix("cargo").tempdir().unwrap();
|
||||||
let p = ProjectBuilder::new("foo", tmpdir.path().to_path_buf()).build();
|
let p = ProjectBuilder::new("foo", tmpdir.path().to_path_buf()).build();
|
||||||
|
|
||||||
assert_that(
|
assert_that(
|
||||||
|
@ -6,7 +6,7 @@ use std::env;
|
|||||||
use cargo::util::ProcessBuilder;
|
use cargo::util::ProcessBuilder;
|
||||||
use cargotest::support::{cargo_exe, execs, paths};
|
use cargotest::support::{cargo_exe, execs, paths};
|
||||||
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||||
use tempdir::TempDir;
|
use tempfile;
|
||||||
|
|
||||||
fn cargo_process(s: &str) -> ProcessBuilder {
|
fn cargo_process(s: &str) -> ProcessBuilder {
|
||||||
let mut p = cargotest::process(&cargo_exe());
|
let mut p = cargotest::process(&cargo_exe());
|
||||||
@ -62,7 +62,7 @@ fn simple_bin() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn both_lib_and_bin() {
|
fn both_lib_and_bin() {
|
||||||
let td = TempDir::new("cargo").unwrap();
|
let td = tempfile::Builder::new().prefix("cargo").tempdir().unwrap();
|
||||||
assert_that(
|
assert_that(
|
||||||
cargo_process("init")
|
cargo_process("init")
|
||||||
.arg("--lib")
|
.arg("--lib")
|
||||||
@ -328,7 +328,7 @@ fn simple_git() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn auto_git() {
|
fn auto_git() {
|
||||||
let td = TempDir::new("cargo").unwrap();
|
let td = tempfile::Builder::new().prefix("cargo").tempdir().unwrap();
|
||||||
let foo = &td.path().join("foo");
|
let foo = &td.path().join("foo");
|
||||||
fs::create_dir_all(&foo).unwrap();
|
fs::create_dir_all(&foo).unwrap();
|
||||||
assert_that(
|
assert_that(
|
||||||
|
@ -13,7 +13,7 @@ extern crate serde_derive;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
extern crate tar;
|
extern crate tar;
|
||||||
extern crate tempdir;
|
extern crate tempfile;
|
||||||
extern crate toml;
|
extern crate toml;
|
||||||
extern crate url;
|
extern crate url;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
@ -7,7 +7,7 @@ use cargo::util::ProcessBuilder;
|
|||||||
use cargotest::process;
|
use cargotest::process;
|
||||||
use cargotest::support::{execs, paths};
|
use cargotest::support::{execs, paths};
|
||||||
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
use hamcrest::{assert_that, existing_dir, existing_file, is_not};
|
||||||
use tempdir::TempDir;
|
use tempfile;
|
||||||
|
|
||||||
fn cargo_process(s: &str) -> ProcessBuilder {
|
fn cargo_process(s: &str) -> ProcessBuilder {
|
||||||
let mut p = cargotest::cargo_process();
|
let mut p = cargotest::cargo_process();
|
||||||
@ -113,7 +113,7 @@ fn simple_git() {
|
|||||||
// Run inside a temp directory so that cargo will initialize a git repo.
|
// Run inside a temp directory so that cargo will initialize a git repo.
|
||||||
// If this ran inside paths::root() it would detect that we are already
|
// If this ran inside paths::root() it would detect that we are already
|
||||||
// inside a git repo and skip the initialization.
|
// inside a git repo and skip the initialization.
|
||||||
let td = TempDir::new("cargo").unwrap();
|
let td = tempfile::Builder::new().prefix("cargo").tempdir().unwrap();
|
||||||
assert_that(
|
assert_that(
|
||||||
cargo_process("new")
|
cargo_process("new")
|
||||||
.arg("--lib")
|
.arg("--lib")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user