diff --git a/Cargo.lock b/Cargo.lock index 69b04815353..e2af7ee1a31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1226,6 +1226,7 @@ name = "integration-tests" version = "0.1.0" dependencies = [ "camino", + "camino-tempfile", "cargo-nextest", "cfg-if", "clap", @@ -1238,7 +1239,6 @@ dependencies = [ "pathdiff", "regex", "serde_json", - "tempfile", ] [[package]] diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index f6a57924689..4dbecf62aba 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -19,11 +19,11 @@ nextest-workspace-hack = { version = "0.1", path = "../workspace-hack" } [dev-dependencies] camino = "1.1.6" +camino-tempfile = "1.0.2" cfg-if = "1.0.0" pathdiff = { version = "0.2.1", features = ["camino"] } nextest-metadata = { version = "=0.9.2", path = "../nextest-metadata" } once_cell = "1.18.0" -tempfile = "3.8.0" regex = "1.9.5" serde_json = "1.0.107" insta = { version = "1.32.0", default-features = false } diff --git a/integration-tests/tests/integration/main.rs b/integration-tests/tests/integration/main.rs index 319d4f94313..8d5e4ffe223 100644 --- a/integration-tests/tests/integration/main.rs +++ b/integration-tests/tests/integration/main.rs @@ -22,16 +22,16 @@ //! cargo-nextest, except it isn't used as the actual test runner. We refer to it with //! `NEXTEST_BIN_EXE_cargo-nextest-dup`. -use camino::{Utf8Path, Utf8PathBuf}; +use camino::Utf8PathBuf; use nextest_metadata::{BuildPlatform, NextestExitCode}; use std::{fs::File, io::Write}; mod fixtures; mod temp_project; +use camino_tempfile::Utf8TempDir; use fixtures::*; use temp_project::TempProject; -use tempfile::TempDir; #[test] fn test_list_default() { @@ -281,11 +281,8 @@ fn test_run_after_build() { fn test_relocated_run() { set_env_vars(); - let custom_target_dir = TempDir::new().unwrap(); - let custom_target_path: &Utf8Path = custom_target_dir - .path() - .try_into() - .expect("tempdir is valid UTF-8"); + let custom_target_dir = Utf8TempDir::new().unwrap(); + let custom_target_path = custom_target_dir.path(); let p = TempProject::new_custom_target_dir(custom_target_path).unwrap(); build_tests(&p); @@ -344,11 +341,8 @@ fn test_relocated_run() { fn test_run_from_archive() { set_env_vars(); - let custom_target_dir = TempDir::new().unwrap(); - let custom_target_path: &Utf8Path = custom_target_dir - .path() - .try_into() - .expect("tempdir is valid UTF-8"); + let custom_target_dir = Utf8TempDir::new().unwrap(); + let custom_target_path = custom_target_dir.path(); let p = TempProject::new_custom_target_dir(custom_target_path).unwrap(); let archive_file = p.temp_root().join("my-archive.tar.zst"); diff --git a/integration-tests/tests/integration/temp_project.rs b/integration-tests/tests/integration/temp_project.rs index 8f1a1a8a41e..3dd77c2d0e3 100644 --- a/integration-tests/tests/integration/temp_project.rs +++ b/integration-tests/tests/integration/temp_project.rs @@ -2,8 +2,8 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use camino::{Utf8Path, Utf8PathBuf}; -use std::{convert::TryInto, fs, io, path::Path}; -use tempfile::TempDir; +use camino_tempfile::Utf8TempDir; +use std::{fs, io, path::Path}; // This isn't general purpose -- it specifically excludes certain directories at the root and is // generally not race-free. @@ -36,7 +36,7 @@ pub(super) fn copy_dir_all( /// This avoid concurrent accesses to the `target` folder. #[derive(Debug)] pub struct TempProject { - temp_dir: Option, + temp_dir: Option, temp_root: Utf8PathBuf, workspace_root: Utf8PathBuf, target_dir: Utf8PathBuf, @@ -52,17 +52,12 @@ impl TempProject { } fn new_impl(custom_target_dir: Option) -> color_eyre::Result { - let temp_dir = tempfile::Builder::new() + let temp_dir = camino_tempfile::Builder::new() .prefix("nextest-fixture") .tempdir()?; // Note: can't use canonicalize here because it ends up creating a UNC path on Windows, // which doesn't match compile time. - let temp_root: Utf8PathBuf = fixup_macos_path( - temp_dir - .path() - .try_into() - .expect("tempdir should be valid UTF-8"), - ); + let temp_root: Utf8PathBuf = fixup_macos_path(temp_dir.path()); let workspace_root = temp_root.join("src"); let src_dir = Utf8Path::new(env!("CARGO_MANIFEST_DIR")) .parent()