test(java): exercise build coordination through overlapping host projects

Цей коміт міститься в:
l0ng-ai committed 2026-12-06 21:20:57 +08:00
1 джерело 7df1f037e1
коміт 36d3ed9901
1 file changed
+44
+44
Переглянути файл
@@ -1578,6 +1578,50 @@ async fn java_multimodule() {
multimodule("java", JAVA_MODULES, "java_multimodule").await;
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
#[ignore = "language smoke: needs jdtls, JDK 21 and Maven"]
async fn java_overlapping_windows() {
const CHILD: &str = "child";
let smoke =
Smoke::open("java", "java-multimodule", &[], Duration::from_secs(300)).await.named("java_overlapping_windows");
let core = smoke.root.join("core");
let file = core.join("src/main/java/com/example/core/Greeter.java");
let class = core.join("target/classes/com/example/core/Greeter.class");
let cancel = ide_core::CancellationToken::new();
ops::doc::doc_open(&smoke.host, WINDOW, file.clone()).await.unwrap();
let parent = smoke.host.project(WINDOW).unwrap();
parent.lsp.wait_jdtls_imported(&file, tokio::time::Instant::now() + smoke.warm_up, &cancel).await.unwrap();
assert_eq!(
ops::java::java_build_workspace(&smoke.host, WINDOW, core.clone(), None).await.unwrap(),
ide_lsp::jdtls::JavaBuildStatus::Succeeded
);
let written = std::fs::metadata(&class).unwrap().modified().unwrap();
tokio::time::sleep(Duration::from_secs(1)).await;
smoke.host.trust.decide(&core, true, false).unwrap();
smoke.host.open_project(CHILD, &core).unwrap();
ops::doc::doc_open(&smoke.host, CHILD, file.clone()).await.unwrap();
let child = smoke.host.project(CHILD).unwrap();
child.lsp.wait_jdtls_imported(&file, tokio::time::Instant::now() + smoke.warm_up, &cancel).await.unwrap();
child.lsp.java_classpath(&core, false, &cancel).await.unwrap();
tokio::time::sleep(Duration::from_secs(2)).await;
assert_eq!(
std::fs::metadata(&class).unwrap().modified().unwrap(),
written,
"the child window rebuilt the same output"
);
eprintln!("Maven parent and child windows imported; no second automatic write to Greeter.class");
let (a, b) = tokio::join!(
ops::java::java_build_workspace(&smoke.host, WINDOW, core.clone(), None),
ops::java::java_build_workspace(&smoke.host, CHILD, core.clone(), None),
);
assert_eq!(a.unwrap(), ide_lsp::jdtls::JavaBuildStatus::Succeeded);
assert_eq!(b.unwrap(), ide_lsp::jdtls::JavaBuildStatus::Succeeded);
eprintln!("both explicit builds succeeded without competing automatic writers");
smoke.host.close_project(CHILD);
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
#[ignore = "language smoke: needs kotlin-lsp, a JDK and Gradle"]
async fn kotlin_restart() {