Skip to content

Commit

Permalink
Move some things around
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Oct 24, 2024
1 parent 07b0797 commit 8e45a28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::{
process::{Command, Output, Stdio},
str::Utf8Error,
};
use tempfile::NamedTempFile;

#[allow(dead_code)]
const DEFAULT_PROFILE: &str = r#"(version 1)
Expand Down Expand Up @@ -65,7 +64,8 @@ pub fn exec_forwarding_output(mut command: Command, failure_is_error: bool) -> R
/// itself.
#[allow(dead_code)]
fn unpack_and_exec(bytes: &[u8]) -> Result<()> {
let (mut file, temp_path) = NamedTempFile::new().map(NamedTempFile::into_parts)?;
let (mut file, temp_path) =
tempfile::NamedTempFile::new().map(tempfile::NamedTempFile::into_parts)?;

file.write_all(bytes)?;

Expand Down Expand Up @@ -239,7 +239,7 @@ fn expand(mut cmd: &str, build_script_path: Option<&Path>) -> Result<String> {

#[cfg(target_os = "macos")]
static BUILD_WRAP_PROFILE_PATH: Lazy<String> = Lazy::new(|| {
let tempfile = NamedTempFile::new().unwrap();
let tempfile = tempfile::NamedTempFile::new().unwrap();
let (mut file, temp_path) = tempfile.into_parts();
let profile = var("BUILD_WRAP_PROFILE").unwrap_or(DEFAULT_PROFILE.to_owned());
let expanded_profile = expand(&profile, None).unwrap();
Expand Down
7 changes: 3 additions & 4 deletions tests/integration/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use std::{
path::Path,
process::Command,
};
use tempfile::{tempdir_in, TempDir};

#[path = "../../src/util/mod.rs"]
mod main_util;
Expand Down Expand Up @@ -55,7 +54,7 @@ pub fn build_with_default_linker() -> Command {
pub fn temp_package<'a, 'b>(
build_script_path: Option<impl AsRef<Path>>,
dependencies: impl IntoIterator<Item = (&'a str, &'b str)>,
) -> Result<TempDir> {
) -> Result<tempfile::TempDir> {
let tempdir = tempdir()?;

write(tempdir.path().join("Cargo.toml"), CARGO_TOML)?;
Expand Down Expand Up @@ -98,8 +97,8 @@ static METADATA: Lazy<Metadata> = Lazy::new(|| MetadataCommand::new().no_deps().
///
/// Useful if you want to verify that writing outside of the temporary directory is forbidden, but
/// `/tmp` is writeable, for example.
pub fn tempdir() -> Result<TempDir> {
tempdir_in(&METADATA.target_directory).map_err(Into::into)
pub fn tempdir() -> Result<tempfile::TempDir> {
tempfile::tempdir_in(&METADATA.target_directory).map_err(Into::into)
}

#[derive(Debug)]
Expand Down

0 comments on commit 8e45a28

Please sign in to comment.