Skip to content

Commit

Permalink
Merge branch 'main' into issue337-FixExecutablePath
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevCraw authored Nov 21, 2024
2 parents 0248dd0 + c659329 commit 749f3d3
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 28 deletions.
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const download = require("gulp-download2");
const cp = require("child_process");

const libertyGroupId = "io.openliberty.tools";
const libertyVersion = "2.1.1";
const libertyVersion = "2.2";
const jakartaGroupId = "org.eclipse.lsp4jakarta";
const jakartaVersion = "0.2.1";
var releaseLevel = "releases"; //"snapshots"; //snapshots or releases
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"./jars/org.eclipse.lsp4jakarta.jdt.core-0.2.1.jar"
],
"xml.javaExtensions": [
"./jars/liberty-langserver-lemminx-2.1.1-jar-with-dependencies.jar"
"./jars/liberty-langserver-lemminx-2.2-jar-with-dependencies.jar"
],
"views": {
"explorer": [
Expand Down Expand Up @@ -275,6 +275,6 @@
"@types/semver": "^7.3.2",
"vscode-languageclient": "^8.1.0",
"xml2js": "^0.5.0",
"jsonpath-plus": "^7.0.0"
"jsonpath-plus": "^10.2.0"
}
}
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { prepareExecutable } from "./util/javaServerStarter";

const LIBERTY_CLIENT_ID = "LANGUAGE_ID_LIBERTY";
const JAKARTA_CLIENT_ID = "LANGUAGE_ID_JAKARTA";
export const LIBERTY_LS_JAR = "liberty-langserver-2.1.1-jar-with-dependencies.jar";
export const LIBERTY_LS_JAR = "liberty-langserver-2.2-jar-with-dependencies.jar";
export const JAKARTA_LS_JAR = "org.eclipse.lsp4jakarta.ls-0.2.1-jar-with-dependencies.jar";

let libertyClient: LanguageClient;
Expand Down
70 changes: 52 additions & 18 deletions src/liberty/devCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,29 +474,27 @@ export async function openReport(reportType: string, libProject?: LibertyProject
const path = Path.dirname(libProject.getPath());
if (path !== undefined) {
let report: any;
if (libProject.getContextValue() === LIBERTY_MAVEN_PROJECT || libProject.getContextValue() === LIBERTY_MAVEN_PROJECT_CONTAINER) {
report = Path.join(path, "target", "site", reportType + "-report.html");
} else if (libProject.getContextValue() === LIBERTY_GRADLE_PROJECT || libProject.getContextValue() === LIBERTY_GRADLE_PROJECT_CONTAINER) {
report = await getGradleTestReport(libProject.path, path);
}
let reportTypeLabel = reportType;
if (reportType === "gradle") {
reportTypeLabel = "test";
}
fs.exists(report, (exists) => {
if (exists) {
const panel = vscode.window.createWebviewPanel(
reportType, // Identifies the type of the webview. Used internally
libProject.getLabel() + " " + reportTypeLabel + " report", // Title of the panel displayed to the user
vscode.ViewColumn.Two, // Open the panel in the second window
{}, // Webview options
);
panel.webview.html = getReport(report); // display HTML content
} else {
const message = localize("test.report.does.not.exist.run.test.first", report);
vscode.window.showInformationMessage(message);
let showErrorMessage: boolean = true;
if (libProject.getContextValue() === LIBERTY_MAVEN_PROJECT || libProject.getContextValue() === LIBERTY_MAVEN_PROJECT_CONTAINER) {
report = getReportFile(path, "reports", reportType + ".html");
// show the error message only if both "reports" and "site" dirs do not contain the test reports
// set to false since this will be the first location checked
showErrorMessage = false;
if (!await checkReportAndDisplay(report, reportType, reportTypeLabel, libProject, showErrorMessage)) {
report = getReportFile(path, "site", reportType + "-report.html");
// show the error message only if both "reports" and "site" dirs do not contain the test reports
// set to true since this will be the second location checked
showErrorMessage = true;
await checkReportAndDisplay(report, reportType, reportTypeLabel, libProject, showErrorMessage);
}
});
} else if (libProject.getContextValue() === LIBERTY_GRADLE_PROJECT || libProject.getContextValue() === LIBERTY_GRADLE_PROJECT_CONTAINER) {
report = await getGradleTestReport(libProject.path, path);
await checkReportAndDisplay(report, reportType, reportTypeLabel, libProject, showErrorMessage);
}
}
} else if (ProjectProvider.getInstance() && reportType) {
showProjects(reportType, openReport, reportType);
Expand Down Expand Up @@ -531,3 +529,39 @@ function createTerminalforLiberty(libProject: LibertyProject, terminal: vscode.T
return terminal;
}

/*
will return the path of the report, since there are diffrent folders to look into and the file names can be different
we need to get the paths to look for dynamically
*/
function getReportFile(path: any, dir: string, filename: string): any {
return Path.join(path, "target", dir, filename);
}

/*
Function will check if the report is available within the given path and returns a boolean based on it and also
the report will be displayed if it is available
*/
function checkReportAndDisplay(report: any, reportType: string, reportTypeLabel: string, libProject: LibertyProject, showErrorMessage: boolean): Promise<boolean> {
return new Promise((resolve) => {
fs.exists(report, (exists) => {
if (exists) {
const panel = vscode.window.createWebviewPanel(
reportType, // Identifies the type of the webview. Used internally
libProject.getLabel() + " " + reportTypeLabel + " report", // Title of the panel displayed to the user
vscode.ViewColumn.Two, // Open the panel in the second window
{}, // Webview options
);
panel.webview.html = getReport(report); // display HTML content
/*
For Maven projects we need to check for the test report in the 'reports' and 'site' dirs.
We only need to show the message if it is not available in both locations.
The `showErrorMessage` flag will only be set to true when checking the second location.
*/
} else if (showErrorMessage) {
const message = localize("test.report.does.not.exist.run.test.first", report);
vscode.window.showInformationMessage(message);
}
resolve(exists);
});
});
}
18 changes: 12 additions & 6 deletions src/test/MavenTestDevModeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ it('Run tests for sample maven project', async () => {
it('start maven with options from liberty dashboard', async () => {

const reportPath = path.join(utils.getMvnProjectPath(),"target","site","failsafe-report.html");
const deleteReport = await utils.deleteReports(reportPath);
expect (deleteReport).to.be.true;
const alternateReportPath = path.join(utils.getMvnProjectPath(), "target", "reports", "failsafe.html"); // new path to scan for the reports
let deleteReport = await utils.deleteReports(reportPath);
let deleteAlternateReport = await utils.deleteReports(alternateReportPath);
expect (deleteReport && deleteAlternateReport).to.be.true; // both report files should either not exist or be successfully deleted
await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM);
await utils.setCustomParameter("-DhotTests=true");
await utils.delay(30000);
Expand All @@ -111,7 +113,8 @@ it('start maven with options from liberty dashboard', async () => {
{
console.log("Server succuessfully started");
let checkFile = await utils.checkIfTestReportExists(reportPath);
expect (checkFile).to.be.true;
let checkAlternateFile = await utils.checkIfTestReportExists(alternateReportPath);
expect (checkFile || checkAlternateFile).to.be.true; // check both potential locations for the test report, one of them must exist
await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION);
const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING);
if(!serverStopStatus){
Expand All @@ -129,8 +132,10 @@ it('start maven with options from liberty dashboard', async () => {
it('start maven with history from liberty dashboard', async () => {

const reportPath = path.join(utils.getMvnProjectPath(),"target","site","failsafe-report.html");
const deleteReport = await utils.deleteReports(reportPath);
expect (deleteReport).to.be.true;
const alternateReportPath = path.join(utils.getMvnProjectPath(), "target", "reports", "failsafe.html");
let deleteReport = await utils.deleteReports(reportPath);
let deleteAlternateReport = await utils.deleteReports(alternateReportPath);
expect (deleteReport && deleteAlternateReport).to.be.true; // both report files should either not exist or be successfully deleted
await utils.launchDashboardAction(item, constants.START_DASHBOARD_ACTION_WITH_PARAM, constants.START_DASHBOARD_MAC_ACTION_WITH_PARAM);
const foundCommand = await utils.chooseCmdFromHistory("-DhotTests=true");
expect (foundCommand).to.be.true;
Expand All @@ -142,7 +147,8 @@ it('start maven with history from liberty dashboard', async () => {
{
console.log("Server succuessfully started");
let checkFile = await utils.checkIfTestReportExists(reportPath);
expect (checkFile).to.be.true;
let checkAlternateFile = await utils.checkIfTestReportExists(alternateReportPath);
expect (checkFile || checkAlternateFile).to.be.true; // check both potential locations for the test report, one of them must exist
await utils.launchDashboardAction(item, constants.STOP_DASHBOARD_ACTION, constants.STOP_DASHBOARD_MAC_ACTION);
const serverStopStatus= await utils.checkTerminalforServerState(constants.SERVER_STOP_STRING);
if(!serverStopStatus){
Expand Down

0 comments on commit 749f3d3

Please sign in to comment.