refactor(monorepo): remove env restore from workspace test
This commit is contained in:
@@ -1,33 +1,9 @@
|
||||
use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use monorepo::workspace::resolve_workspace_path;
|
||||
|
||||
const BUILD_WORKSPACE_DIRECTORY: &str = "BUILD_WORKSPACE_DIRECTORY";
|
||||
|
||||
struct EnvRestore {
|
||||
value: Option<OsString>,
|
||||
}
|
||||
|
||||
impl EnvRestore {
|
||||
fn capture() -> Self {
|
||||
Self {
|
||||
value: std::env::var_os(BUILD_WORKSPACE_DIRECTORY),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for EnvRestore {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
if let Some(value) = &self.value {
|
||||
std::env::set_var(BUILD_WORKSPACE_DIRECTORY, value);
|
||||
} else {
|
||||
std::env::remove_var(BUILD_WORKSPACE_DIRECTORY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Case {
|
||||
@@ -39,8 +15,6 @@ struct Case {
|
||||
|
||||
#[test]
|
||||
fn resolve_workspace_path_cases() {
|
||||
let _restore = EnvRestore::capture();
|
||||
|
||||
let cases = [
|
||||
Case {
|
||||
name: "absolute path returns unchanged path",
|
||||
|
||||
Reference in New Issue
Block a user