Bug 1545960 - Part 1: Replace tempdir by tempfile. r=ato

tempdir has been deprecated for a while. I've set tempfile to 3.0.2 on
purpose to avoid duping rand for now (but this is one more step in the
direction of getting everything to rand 0.6 as tempfile 3 is on it
already).

Differential Revision: https://phabricator.services.mozilla.com/D28278

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bastien Orivel 2019-05-08 09:49:24 +00:00
parent 5157e26d94
commit 81ccf6ca5b
6 changed files with 27 additions and 14 deletions

25
Cargo.lock generated
View File

@ -308,7 +308,7 @@ dependencies = [
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -1849,7 +1849,7 @@ dependencies = [
name = "mozprofile"
version = "0.5.0"
dependencies = [
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -2398,6 +2398,14 @@ dependencies = [
"ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "remove_dir_all"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.6 (git+https://github.com/froydnj/winapi-rs?branch=aarch64)",
]
[[package]]
name = "rkv"
version = "0.9.4"
@ -2896,11 +2904,15 @@ dependencies = [
]
[[package]]
name = "tempdir"
version = "0.3.5"
name = "tempfile"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.51 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (git+https://github.com/froydnj/winapi-rs?branch=aarch64)",
]
[[package]]
@ -3813,6 +3825,7 @@ dependencies = [
"checksum regex 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3d8c9f33201f46669484bacc312b00e7541bed6aaf296dffe2bb4e0ac6b8ce2a"
"checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
"checksum regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1ac0f60d675cc6cf13a20ec076568254472551051ad5dd050364d70671bf6b"
"checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5"
"checksum rkv 0.9.4 (registry+https://github.com/rust-lang/crates.io-index)" = "238764bd8750927754d91e4a27155ac672ba88934a2bf698c992d55e5ae25e5b"
"checksum ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "da06feaa07f69125ab9ddc769b11de29090122170b402547f64b86fe16ebc399"
"checksum runloop 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d79b4b604167921892e84afbbaad9d5ad74e091bf6c511d9dbfb0593f09fabd"
@ -3855,7 +3868,7 @@ dependencies = [
"checksum syn 0.15.30 (registry+https://github.com/rust-lang/crates.io-index)" = "66c8865bf5a7cbb662d8b011950060b3c8743dca141b054bf7195b20d314d8e2"
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
"checksum target-lexicon 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0ab4982b8945c35cc1c46a83a9094c414f6828a099ce5dcaa8ee2b04642dcb"
"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6"
"checksum tempfile 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "47776f63b85777d984a50ce49d6b9e58826b6a3766a449fc95bc66cd5663c15b"
"checksum term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "fa63644f74ce96fbeb9b794f66aff2a52d601cbd5e80f4b97123e3899f4570f1"
"checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209"
"checksum termcolor 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "adc4587ead41bf016f11af03e55a624c06568b5a19db4e90fde573d805074f83"

View File

@ -7,4 +7,4 @@ repository = "https://hg.mozilla.org/mozilla-central/file/tip/testing/mozbase/ru
license = "MPL-2.0"
[dependencies]
tempdir = "0.3.4"
tempfile = "3"

View File

@ -1,4 +1,4 @@
extern crate tempdir;
extern crate tempfile;
pub mod preferences;
pub mod prefreader;

View File

@ -5,7 +5,7 @@ use std::fs::File;
use std::io::prelude::*;
use std::io::Result as IoResult;
use std::path::{Path, PathBuf};
use tempdir::TempDir;
use tempfile::{Builder, TempDir};
#[derive(Debug)]
pub struct Profile {
@ -17,7 +17,7 @@ pub struct Profile {
impl Profile {
pub fn new() -> IoResult<Profile> {
let dir = TempDir::new("rust_mozprofile")?;
let dir = Builder::new().prefix("rust_mozprofile").tempdir()?;
let path = dir.path().to_path_buf();
let temp_dir = Some(dir);
Ok(Profile {

View File

@ -23,4 +23,4 @@ version = "0.1.3"
lazy_static = "1.0.1"
rand = "0.4.3"
regex = "1"
tempdir = "0.3.5"
tempfile = "3"

View File

@ -14,7 +14,7 @@ extern crate bits;
extern crate lazy_static;
extern crate rand;
extern crate regex;
extern crate tempdir;
extern crate tempfile;
use std::ffi::{OsStr, OsString};
use std::fs::{self, File};
@ -30,7 +30,7 @@ use self::{
lazy_static::lazy_static,
rand::{thread_rng, Rng},
regex::bytes::Regex,
tempdir::TempDir,
tempfile::{Builder, TempDir},
};
use super::{
super::{BitsJobState, Error},
@ -252,7 +252,7 @@ macro_rules! test {
#[test]
fn $name() {
let $param = stringify!($name);
let $tmpdir = &TempDir::new($param).unwrap();
let $tmpdir = &Builder::new().prefix($param).tempdir().unwrap();
let result = panic::catch_unwind(|| $body);