Compare commits

...
Author SHA1 Message Date
l0ng-ai 8c33459fcd fix(gradle): keep task descriptions in row tooltips 2026-11-23 08:05:57 +08:00
l0ng-ai 844c2f3145 test(maven): wait for the background refresh of jdtls import roots (#5272)
external_maven_link_persists_reloads_and_unlink_keeps_files failed on the macOS runner: setting languages.java.maven.linkedProjects refreshes the language server's import roots on a blocking task, and the test read them right after build_model returned. It now waits up to 5 s for them to change.
2026-11-23 05:18:24 +08:00
4 changed files with 25 additions and 6 deletions

No files matched your search

+15 -2
View File
@@ -49,7 +49,7 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
assert_eq!(b.pom, canonical);
assert_eq!(dunce::canonicalize(root.join(&b.dir)).unwrap(), sibling);
assert_eq!(host.project("main").unwrap().content_roots(), vec![sibling.clone()]);
assert_eq!(host.project("main").unwrap().lsp.jdtls_import_roots(), vec![sibling.clone()]);
assert_eq!(import_roots(&host, |roots| !roots.is_empty()).await, vec![sibling.clone()]);
let reloaded = ops::build::build_model(&host, "main").await.unwrap();
assert_eq!(
@@ -63,13 +63,26 @@ async fn external_maven_link_persists_reloads_and_unlink_keeps_files() {
let gone = ops::build::build_model(&host, "main").await.unwrap();
assert!(gone.maven.unwrap().projects.iter().all(|p| p.artifact_id != "b"));
assert!(host.project("main").unwrap().content_roots().is_empty());
assert!(host.project("main").unwrap().lsp.jdtls_import_roots().is_empty());
assert!(import_roots(&host, |roots| roots.is_empty()).await.is_empty());
assert_eq!(saved(), Vec::<String>::new());
assert_eq!(std::fs::read_to_string(root.join("pom.xml")).unwrap(), a_pom);
assert_eq!(std::fs::read_to_string(sibling.join("pom.xml")).unwrap(), b_pom);
host.shutdown().await;
}
/// The language server's Maven import roots once `ready` holds: a settings change refreshes them in
/// the background.
async fn import_roots(host: &Host, ready: impl Fn(&[std::path::PathBuf]) -> bool) -> Vec<std::path::PathBuf> {
for _ in 0..200 {
let roots = host.project("main").unwrap().lsp.jdtls_import_roots();
if ready(&roots) {
return roots;
}
tokio::time::sleep(std::time::Duration::from_millis(25)).await;
}
host.project("main").unwrap().lsp.jdtls_import_roots()
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn reactor_module_beside_a_trusted_project_is_a_content_root_until_removed() {
let temp = tempfile::tempdir().unwrap();
+4
View File
@@ -83,6 +83,10 @@ test("links independent Gradle roots, runs identical task paths in their own bui
});
const tasks = tree.getByRole("treeitem", { name: /^assemble\b/ });
await expect(tasks).toHaveCount(2);
expect(await tasks.allTextContents()).toEqual(["assemble", "assemble"]);
for (const task of await tasks.all()) {
await expect(task).toHaveAccessibleDescription("Assembles this project");
}
await page.screenshot({ path: info.outputPath("gradle-two-roots.png"), animations: "disabled" });
await tasks.nth(0).dblclick();
+3 -4
View File
@@ -317,14 +317,12 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
? `(${node.dependency.scope}${node.dependency.optional ? ", optional" : ""})`
: node.kind === "dependency" && node.dependency.optional
? "(optional)"
: node.kind === "task"
? node.task.description
: null;
: null;
const skipped =
(mavenSkipTests && node.kind === "phase" && node.phase === "test") ||
(gradleSkipTests && node.kind === "task" && node.task.name === "test");
return (
<span className={styles.row} title={node.kind === "task" ? (node.task.description ?? undefined) : undefined}>
<span className={styles.row}>
<Icon name={nodeIcon(node)} size={16} className={styles.icon} />
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
{nodeLabel(node)}
@@ -475,6 +473,7 @@ function BuildToolView({ tool }: { tool: BuildTool }) {
roots={roots}
getKey={(n) => n.key}
getLabel={nodeLabel}
getTooltip={(n) => (n.kind === "task" ? (n.task.description ?? undefined) : undefined)}
getChildren={getChildren}
isExpandable={(n) => !!getChildren(n)?.length}
expanded={expanded}
+3
View File
@@ -93,6 +93,8 @@ export interface TreeProps<T> {
getIcon?: (node: T, expanded: boolean) => IconName | (string & {}) | undefined;
/** Muted trailing detail (e.g. a path next to the project root); may include styled content. */
getDetail?: (node: T) => ReactNode;
/** Native tooltip and accessible description for a row. */
getTooltip?: (node: T) => string | undefined;
/** Label colour, e.g. VCS status. */
getColor?: (node: T) => string | undefined;
/** Filesystem directory for actions on the focused selection; groups return null. */
@@ -800,6 +802,7 @@ export function Tree<T>(props: TreeProps<T>) {
aria-setsize={positions[v.index]![1]}
aria-expanded={row.expandable ? row.expanded : undefined}
aria-selected={isSelected}
title={props.getTooltip?.(row.node)}
className={clsx(
styles.row,
props.horizontalScroll && styles.wideRow,