mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 17:02:17 +00:00
fix(test): isolate plugin process environment rejection fixture (#2059)
The plugin process-environment test looked for Git only on a Windows user PATH, so it failed before reaching its assertions when Git was on the system PATH. It now pins a temporary, deliberately unspawnable file, so both process APIs must reject environment overrides before anything runs, and it uses the platform's key comparison when picking a second inherited variable. Co-authored-by: arnaud-ritti <[email protected]>
This commit is contained in:
1 parent
3ee5471ca2
commit
34c8f87ba7
1 file changed
+9
-8
@@ -2186,23 +2186,24 @@ mod tests {
|
||||
#[test]
|
||||
fn process_environment_only_adds_variables() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let binary = ide_core::process::find_executable(
|
||||
"git",
|
||||
&ide_core::process::user_path().or_else(|| std::env::var_os("PATH")).unwrap(),
|
||||
)
|
||||
.expect("git on PATH");
|
||||
// Environment overrides must be rejected before spawn, so no executable is needed.
|
||||
let binary = tmp.path().join("lint.exe");
|
||||
std::fs::write(&binary, "not an executable").unwrap();
|
||||
let pins: Arc<RwLock<HashMap<(String, String), ProgramPin>>> = Arc::default();
|
||||
pins.write().insert(("acme.lint".into(), "process:git".into()), ProgramPin::approve(&binary).unwrap());
|
||||
pins.write().insert(("acme.lint".into(), "process:lint".into()), ProgramPin::approve(&binary).unwrap());
|
||||
let api = api(tmp.path(), pins);
|
||||
let inherited = std::env::vars_os()
|
||||
.find(|(key, _)| key != "PATH" && key.to_str().is_some_and(|key| !key.is_empty() && !key.contains('=')))
|
||||
.find(|(key, _)| {
|
||||
!env_name_eq(key, "PATH".as_ref())
|
||||
&& key.to_str().is_some_and(|key| !key.is_empty() && !key.contains('='))
|
||||
})
|
||||
.unwrap()
|
||||
.0
|
||||
.into_string()
|
||||
.unwrap();
|
||||
for key in ["PATH".to_owned(), inherited] {
|
||||
let cmd = ProcessCommand {
|
||||
program: "git".into(),
|
||||
program: "lint".into(),
|
||||
env: vec![(key.clone(), "replacement".into())],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user