run_make_support: rename env_checked -> env

This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-07-17 11:17:28 +00:00
parent b7f7205212
commit a443dc4ecd
8 changed files with 10 additions and 11 deletions

View File

@ -1,10 +1,9 @@
use std::env;
use std::ffi::OsString; use std::ffi::OsString;
#[track_caller] #[track_caller]
#[must_use] #[must_use]
pub fn env_var(name: &str) -> String { pub fn env_var(name: &str) -> String {
match env::var(name) { match std::env::var(name) {
Ok(v) => v, Ok(v) => v,
Err(err) => panic!("failed to retrieve environment variable {name:?}: {err:?}"), Err(err) => panic!("failed to retrieve environment variable {name:?}: {err:?}"),
} }
@ -13,7 +12,7 @@ pub fn env_var(name: &str) -> String {
#[track_caller] #[track_caller]
#[must_use] #[must_use]
pub fn env_var_os(name: &str) -> OsString { pub fn env_var_os(name: &str) -> OsString {
match env::var_os(name) { match std::env::var_os(name) {
Some(v) => v, Some(v) => v,
None => panic!("failed to retrieve environment variable {name:?}"), None => panic!("failed to retrieve environment variable {name:?}"),
} }

View File

@ -1,7 +1,7 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use crate::command::Command; use crate::command::Command;
use crate::env_checked::env_var; use crate::env::env_var;
/// Construct a new `llvm-readobj` invocation with the `GNU` output style. /// Construct a new `llvm-readobj` invocation with the `GNU` output style.
/// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`. /// This assumes that `llvm-readobj` is available at `$LLVM_BIN_DIR/llvm-readobj`.

View File

@ -1,5 +1,5 @@
use crate::command::Command; use crate::command::Command;
use crate::env_checked::env_var; use crate::env::env_var;
/// Obtain path of python as provided by the `PYTHON` environment variable. It is up to the caller /// Obtain path of python as provided by the `PYTHON` environment variable. It is up to the caller
/// to document and check if the python version is compatible with its intended usage. /// to document and check if the python version is compatible with its intended usage.

View File

@ -2,7 +2,7 @@
use std::path::Path; use std::path::Path;
use crate::command::Command; use crate::command::Command;
use crate::env_checked::env_var; use crate::env::env_var;
use crate::path_helpers::cwd; use crate::path_helpers::cwd;
use crate::util::set_host_rpath; use crate::util::set_host_rpath;

View File

@ -2,7 +2,7 @@
use std::path::Path; use std::path::Path;
use crate::command::Command; use crate::command::Command;
use crate::env_checked::{env_var, env_var_os}; use crate::env::{env_var, env_var_os};
use crate::util::set_host_rpath; use crate::util::set_host_rpath;
/// Construct a plain `rustdoc` invocation with no flags set. /// Construct a plain `rustdoc` invocation with no flags set.

View File

@ -10,7 +10,7 @@
pub mod artifact_names; pub mod artifact_names;
pub mod assertion_helpers; pub mod assertion_helpers;
pub mod diff; pub mod diff;
pub mod env_checked; pub mod env;
pub mod external_deps; pub mod external_deps;
pub mod fs_helpers; pub mod fs_helpers;
pub mod fs_wrapper; pub mod fs_wrapper;
@ -48,7 +48,7 @@
pub use diff::{diff, Diff}; pub use diff::{diff, Diff};
/// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers. /// Panic-on-fail [`std::env::var`] and [`std::env::var_os`] wrappers.
pub use env_checked::{env_var, env_var_os}; pub use env::{env_var, env_var_os};
/// Convenience helpers for running binaries and other commands. /// Convenience helpers for running binaries and other commands.
pub use run::{cmd, run, run_fail, run_with_args}; pub use run::{cmd, run, run_fail, run_with_args};

View File

@ -4,7 +4,7 @@
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use crate::command::Command; use crate::command::Command;
use crate::env_checked::env_var; use crate::env::env_var;
use crate::util::handle_failed_output; use crate::util::handle_failed_output;
/// Return the current working directory. /// Return the current working directory.

View File

@ -1,7 +1,7 @@
use std::path::PathBuf; use std::path::PathBuf;
use crate::command::{Command, CompletedProcess}; use crate::command::{Command, CompletedProcess};
use crate::env_checked::env_var; use crate::env::env_var;
use crate::path_helpers::cwd; use crate::path_helpers::cwd;
/// If a given [`Command`] failed (as indicated by its [`CompletedProcess`]), verbose print the /// If a given [`Command`] failed (as indicated by its [`CompletedProcess`]), verbose print the