mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 06:50:54 +07:00
[remote dev launcher] unset environment variables set by remote-dev-server launcher when starting processes from the IDE (GTW-9586)
EnvironmentRestorer removes variables from the environment for processes started from the IDE if the corresponding INTELLIJ_ORIGINAL_ENV _ variable is set to empty string. So the native launcher should set empty value for variables set by it like it is done in the old launcher.sh. GitOrigin-RevId: 1a3b69637f52e5f654a21911155567e042ff20ac
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d8b290f19f
commit
d23d55e2a8
@@ -452,12 +452,16 @@ fn init_env_vars(ide_home_path: &Path) -> Result<()> {
|
||||
}
|
||||
|
||||
for (key, value) in remote_dev_env_var_values {
|
||||
let backup_key = format!("INTELLIJ_ORIGINAL_ENV_{key}");
|
||||
if let Ok(old_value) = env::var(key) {
|
||||
let backup_key = format!("INTELLIJ_ORIGINAL_ENV_{key}");
|
||||
debug!("'{key}' has already been assigned the value {old_value}, overriding to {value}. \
|
||||
Old value will be preserved for child processes.");
|
||||
env::set_var(backup_key, old_value)
|
||||
}
|
||||
else {
|
||||
debug!("'{key}' was set to {value}. It will be unset for child processes.");
|
||||
env::set_var(backup_key, "")
|
||||
}
|
||||
|
||||
env::set_var(key, value)
|
||||
}
|
||||
|
||||
@@ -112,11 +112,11 @@ mod tests {
|
||||
fn remote_dev_font_config_added_test() {
|
||||
let test = prepare_test_env(LauncherLocation::RemoteDev);
|
||||
prepare_font_config_dir(&test.dist_root);
|
||||
let remote_dev_command = &["printEnvVar", "FONTCONFIG_PATH"];
|
||||
let launch_result = run_launcher_ext(&test, LauncherRunSpec::remote_dev().with_args(remote_dev_command));
|
||||
|
||||
let expected_output = format!("FONTCONFIG_PATH={}/jbrd-fontconfig-", std::env::temp_dir().to_string_lossy());
|
||||
check_output(&launch_result, |output| output.contains(&expected_output));
|
||||
let expected_path_value = format!("{}/jbrd-fontconfig-", std::env::temp_dir().to_string_lossy());
|
||||
let env = HashMap::new();
|
||||
check_env_variable(&test, &env, "FONTCONFIG_PATH", expected_path_value);
|
||||
check_env_variable(&test, &env, "INTELLIJ_ORIGINAL_ENV_FONTCONFIG_PATH", "\n".to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -125,10 +125,16 @@ mod tests {
|
||||
let test = prepare_test_env(LauncherLocation::RemoteDev);
|
||||
let env = HashMap::from([("FONTCONFIG_PATH", "/some/existing/path")]);
|
||||
prepare_font_config_dir(&test.dist_root);
|
||||
let remote_dev_command = &["printEnvVar", "FONTCONFIG_PATH"];
|
||||
let launch_result = run_launcher_ext(&test, LauncherRunSpec::remote_dev().with_env(&env).with_args(remote_dev_command));
|
||||
let expected_path_value = format!("/some/existing/path:{}/jbrd-fontconfig-", std::env::temp_dir().to_string_lossy());
|
||||
check_env_variable(&test, &env, "FONTCONFIG_PATH", expected_path_value);
|
||||
check_env_variable(&test, &env, "INTELLIJ_ORIGINAL_ENV_FONTCONFIG_PATH", "/some/existing/path".to_string());
|
||||
}
|
||||
|
||||
let expected_output = format!("FONTCONFIG_PATH=/some/existing/path:{}/jbrd-fontconfig-", std::env::temp_dir().to_string_lossy());
|
||||
fn check_env_variable(test: &TestEnvironment, env: &HashMap<&str, &str>, variable_name: &str, expected_value: String) {
|
||||
let remote_dev_command = &["printEnvVar", variable_name];
|
||||
let launch_result = run_launcher_ext(&test, LauncherRunSpec::remote_dev().with_env(env).with_args(remote_dev_command));
|
||||
|
||||
let expected_output = format!("{}={}", variable_name, expected_value);
|
||||
check_output(&launch_result, |output| output.contains(&expected_output));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user