Skip to content

Commit 723b080

Browse files
committed
Clarify which subproject when necessary for attach debugger and view test report
1 parent 5166fd4 commit 723b080

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/liberty/devCommands.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -573,29 +573,38 @@ export async function runTests(libProject?: LibertyProject | undefined): Promise
573573
// open surefire, failsafe, or gradle test report
574574
export async function openReport(reportType: string, libProject?: LibertyProject | undefined): Promise<void> {
575575
if (libProject !== undefined) {
576-
const path = Path.dirname(libProject.getPath());
576+
// Resolve the target project (handles aggregators with multiple Liberty children)
577+
const projectProvider: ProjectProvider = ProjectProvider.getInstance();
578+
const targetProject = await projectProvider.resolveCommandTarget(libProject, localize("command.view.test.report"));
579+
580+
if (targetProject === undefined) {
581+
// User cancelled or no valid target found
582+
return;
583+
}
584+
585+
const path = Path.dirname(targetProject.getPath());
577586
if (path !== undefined) {
578587
let report: any;
579588
let reportTypeLabel = reportType;
580589
if (reportType === "gradle") {
581590
reportTypeLabel = "test";
582591
}
583592
let showErrorMessage: boolean = true;
584-
if (libProject.getContextValue() === LIBERTY_MAVEN_PROJECT || libProject.getContextValue() === LIBERTY_MAVEN_PROJECT_CONTAINER) {
593+
if (targetProject.getContextValue() === LIBERTY_MAVEN_PROJECT || targetProject.getContextValue() === LIBERTY_MAVEN_PROJECT_CONTAINER) {
585594
report = getReportFile(path, "reports", reportType + ".html");
586595
// show the error message only if both "reports" and "site" dirs do not contain the test reports
587596
// set to false since this will be the first location checked
588-
showErrorMessage = false;
589-
if (!await checkReportAndDisplay(report, reportType, reportTypeLabel, libProject, showErrorMessage)) {
597+
showErrorMessage = false;
598+
if (!await checkReportAndDisplay(report, reportType, reportTypeLabel, targetProject, showErrorMessage)) {
590599
report = getReportFile(path, "site", reportType + "-report.html");
591600
// show the error message only if both "reports" and "site" dirs do not contain the test reports
592601
// set to true since this will be the second location checked
593-
showErrorMessage = true;
594-
await checkReportAndDisplay(report, reportType, reportTypeLabel, libProject, showErrorMessage);
602+
showErrorMessage = true;
603+
await checkReportAndDisplay(report, reportType, reportTypeLabel, targetProject, showErrorMessage);
595604
}
596-
} else if (libProject.getContextValue() === LIBERTY_GRADLE_PROJECT || libProject.getContextValue() === LIBERTY_GRADLE_PROJECT_CONTAINER) {
597-
report = await getGradleTestReport(libProject.path, path);
598-
await checkReportAndDisplay(report, reportType, reportTypeLabel, libProject, showErrorMessage);
605+
} else if (targetProject.getContextValue() === LIBERTY_GRADLE_PROJECT || targetProject.getContextValue() === LIBERTY_GRADLE_PROJECT_CONTAINER) {
606+
report = await getGradleTestReport(targetProject.path, path);
607+
await checkReportAndDisplay(report, reportType, reportTypeLabel, targetProject, showErrorMessage);
599608
}
600609
}
601610
} else if (ProjectProvider.getInstance() && reportType) {

src/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,6 @@
8181
"command.start.custom.dev.mode": "start custom dev mode",
8282
"command.stop.dev.mode": "stop dev mode",
8383
"command.run.tests": "run tests",
84-
"command.attach.debugger": "attach debugger"
84+
"command.attach.debugger": "attach debugger",
85+
"command.view.test.report": "view test report"
8586
}

0 commit comments

Comments
 (0)