Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[integration-tests] use camino-tempfile #982

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
18 changes: 6 additions & 12 deletions integration-tests/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down
15 changes: 5 additions & 10 deletions integration-tests/tests/integration/temp_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<TempDir>,
temp_dir: Option<Utf8TempDir>,
temp_root: Utf8PathBuf,
workspace_root: Utf8PathBuf,
target_dir: Utf8PathBuf,
Expand All @@ -52,17 +52,12 @@ impl TempProject {
}

fn new_impl(custom_target_dir: Option<Utf8PathBuf>) -> color_eyre::Result<Self> {
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()
Expand Down
Loading