mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
Cleanup (rearranging test methods; linter warnings; typos)
GitOrigin-RevId: 2994970f6f993b313638701d5278eb7b96b93ecb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
18e92f38e7
commit
c6eb8f1051
@@ -4,8 +4,9 @@ pub mod utils;
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use xplat_launcher::jvm_property;
|
use xplat_launcher::{get_config_home, jvm_property};
|
||||||
use crate::utils::*;
|
use crate::utils::*;
|
||||||
|
|
||||||
/// Tests depending on the shared user config directory cannot run concurrently.
|
/// Tests depending on the shared user config directory cannot run concurrently.
|
||||||
@@ -18,7 +19,7 @@ mod tests {
|
|||||||
|
|
||||||
let expected_rt = test.create_jbr_link("_user_jbr");
|
let expected_rt = test.create_jbr_link("_user_jbr");
|
||||||
let jdk_config_name = if cfg!(target_os = "windows") { "xplat64.exe.jdk" } else { "xplat.jdk" };
|
let jdk_config_name = if cfg!(target_os = "windows") { "xplat64.exe.jdk" } else { "xplat.jdk" };
|
||||||
test.create_user_config_file(jdk_config_name, expected_rt.to_str().unwrap(), get_custom_config_dir());
|
test.create_user_config_file(jdk_config_name, expected_rt.to_str().unwrap(), get_standard_config_dir());
|
||||||
|
|
||||||
let result = run_launcher_ext(&test, LauncherRunSpec::standard().assert_status());
|
let result = run_launcher_ext(&test, LauncherRunSpec::standard().assert_status());
|
||||||
test_runtime_selection(result, expected_rt);
|
test_runtime_selection(result, expected_rt);
|
||||||
@@ -30,7 +31,7 @@ mod tests {
|
|||||||
let mut test = prepare_test_env(LauncherLocation::Standard);
|
let mut test = prepare_test_env(LauncherLocation::Standard);
|
||||||
|
|
||||||
let vm_options_name = get_vm_options_name();
|
let vm_options_name = get_vm_options_name();
|
||||||
let vm_options_file = test.create_user_config_file(vm_options_name, "-Done.user.option=whatever\n", get_custom_config_dir());
|
let vm_options_file = test.create_user_config_file(vm_options_name, "-Done.user.option=whatever\n", get_standard_config_dir());
|
||||||
|
|
||||||
let dump = run_launcher_ext(&test, LauncherRunSpec::standard().with_dump().assert_status()).dump();
|
let dump = run_launcher_ext(&test, LauncherRunSpec::standard().with_dump().assert_status()).dump();
|
||||||
|
|
||||||
@@ -47,10 +48,17 @@ mod tests {
|
|||||||
let mut test = prepare_test_env(LauncherLocation::Standard);
|
let mut test = prepare_test_env(LauncherLocation::Standard);
|
||||||
|
|
||||||
let vm_options_name = get_vm_options_name();
|
let vm_options_name = get_vm_options_name();
|
||||||
let custom_config_dir = get_jetbrains_config_root().join("XPlatLauncherTestCustom");
|
test.create_user_config_file(vm_options_name, "-Dcustom.property=custom.value\n", get_custom_config_dir());
|
||||||
test.create_user_config_file(vm_options_name, "-Dcustom.property=custom.value\n", custom_config_dir);
|
|
||||||
|
|
||||||
let result = run_launcher(LauncherRunSpec::standard().with_args(&["custom-command"]).assert_status());
|
let result = run_launcher(LauncherRunSpec::standard().with_args(&["custom-command"]).assert_status());
|
||||||
assert!(result.stdout.contains("Custom command: product.property=product.value, custom.property=custom.value"), "Custom system property is not set: {:?}", result);
|
assert!(result.stdout.contains("Custom command: product.property=product.value, custom.property=custom.value"), "Custom system property is not set: {:?}", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_standard_config_dir() -> PathBuf {
|
||||||
|
get_config_home().unwrap().join("JetBrains").join("XPlatLauncherTest")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_custom_config_dir() -> PathBuf {
|
||||||
|
get_config_home().unwrap().join("JetBrains").join("XPlatLauncherTestCustom")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use log::debug;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tempfile::{Builder, TempDir};
|
use tempfile::{Builder, TempDir};
|
||||||
|
|
||||||
use xplat_launcher::{DEBUG_MODE_ENV_VAR, get_config_home, PathExt};
|
use xplat_launcher::{DEBUG_MODE_ENV_VAR, PathExt};
|
||||||
|
|
||||||
static INIT: Once = Once::new();
|
static INIT: Once = Once::new();
|
||||||
static mut SHARED: Option<TestEnvironmentShared> = None;
|
static mut SHARED: Option<TestEnvironmentShared> = None;
|
||||||
@@ -208,7 +208,7 @@ fn init_test_environment_once() -> Result<TestEnvironmentShared> {
|
|||||||
let product_info_path = project_root.join(format!("resources/product_info_{}.json", env::consts::OS));
|
let product_info_path = project_root.join(format!("resources/product_info_{}.json", env::consts::OS));
|
||||||
let vm_options_path = project_root.join("resources/xplat.vmoptions");
|
let vm_options_path = project_root.join("resources/xplat.vmoptions");
|
||||||
|
|
||||||
// on build agents, a temp directory may reside in a different filesystem, so copies are needed for later linking
|
// on build agents, a temp directory may reside in a different filesystem, so copies are necessary for later linking
|
||||||
let temp_dir = Builder::new().prefix("xplat_launcher_shared_").tempdir().context("Failed to create temp directory")?;
|
let temp_dir = Builder::new().prefix("xplat_launcher_shared_").tempdir().context("Failed to create temp directory")?;
|
||||||
let launcher_path = temp_dir.path().join(launcher_file.file_name().unwrap());
|
let launcher_path = temp_dir.path().join(launcher_file.file_name().unwrap());
|
||||||
fs::copy(&launcher_file, &launcher_path).with_context(|| format!("Failed to copy {launcher_file:?} to {launcher_path:?}"))?;
|
fs::copy(&launcher_file, &launcher_path).with_context(|| format!("Failed to copy {launcher_file:?} to {launcher_path:?}"))?;
|
||||||
@@ -422,14 +422,6 @@ fn symlink(original: &Path, link: &Path) -> Result<()> {
|
|||||||
result.with_context(|| format!("Failed to create symlink {link:?} -> {original:?}; {message}"))
|
result.with_context(|| format!("Failed to create symlink {link:?} -> {original:?}; {message}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_custom_config_dir() -> PathBuf {
|
|
||||||
get_jetbrains_config_root().join("XPlatLauncherTest")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_jetbrains_config_root() -> PathBuf {
|
|
||||||
get_config_home().unwrap().join("JetBrains")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct LauncherRunSpec {
|
pub struct LauncherRunSpec {
|
||||||
location: LauncherLocation,
|
location: LauncherLocation,
|
||||||
dump: bool,
|
dump: bool,
|
||||||
@@ -607,7 +599,7 @@ fn read_output_file(path: &Path) -> Result<String> {
|
|||||||
if let Ok(string) = String::from_utf8(bytes.to_owned()) {
|
if let Ok(string) = String::from_utf8(bytes.to_owned()) {
|
||||||
Ok(string)
|
Ok(string)
|
||||||
} else {
|
} else {
|
||||||
for line in bytes.split(|b| *b == '\n' as u8) {
|
for line in bytes.split(|b| *b == b'\n') {
|
||||||
if let Err(e) = String::from_utf8(line.to_owned()) {
|
if let Err(e) = String::from_utf8(line.to_owned()) {
|
||||||
bail!("{}: {:?} {:?}", e, line, String::from_utf8_lossy(line))
|
bail!("{}: {:?} {:?}", e, line, String::from_utf8_lossy(line))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user