From 36d3ed990129abb9d8acce36971ab9b922eb2368 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Sun, 6 Dec 2026 21:20:57 +0800 Subject: [PATCH] test(java): exercise build coordination through overlapping host projects --- crates/ide-host/tests/language_smoke.rs | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/crates/ide-host/tests/language_smoke.rs b/crates/ide-host/tests/language_smoke.rs index 5990d894bd..6a6cf4a69b 100644 --- a/crates/ide-host/tests/language_smoke.rs +++ b/crates/ide-host/tests/language_smoke.rs @@ -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() {