Skip to content

Commit

Permalink
Changes after review cmments for report issue fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshwinThomasIBM authored and JoshwinThomasIBM committed Oct 29, 2024
1 parent 19effba commit 673ac0c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
13 changes: 5 additions & 8 deletions src/liberty/devCommands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2020, 2022 IBM Corporation.
* Copyright (c) 2020, 2024 IBM Corporation.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -490,7 +490,6 @@ export async function openReport(reportType: string, libProject?: LibertyProject
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");
report = getReportFile(path,"reports",reportType+".html");
} else if (libProject.getContextValue() === LIBERTY_GRADLE_PROJECT || libProject.getContextValue() === LIBERTY_GRADLE_PROJECT_CONTAINER) {
report = await getGradleTestReport(libProject.path, path);
Expand All @@ -501,14 +500,14 @@ export async function openReport(reportType: string, libProject?: LibertyProject
}
if(libProject.getContextValue() === LIBERTY_MAVEN_PROJECT || libProject.getContextValue() === LIBERTY_MAVEN_PROJECT_CONTAINER){
console.log("report path ::"+report)
if(!await checkReportExists(report,reportType,reportTypeLabel,libProject)){
if(!await checkReportAndDisplay(report,reportType,reportTypeLabel,libProject)){
report = getReportFile(path,"site",reportType+"-report.html");
if(!await checkReportExists(report,reportType,reportTypeLabel,libProject)){
if(!await checkReportAndDisplay(report,reportType,reportTypeLabel,libProject)){
const message = localize("test.report.does.not.exist.run.test.first", report);
vscode.window.showInformationMessage(message);
}
}
}else if(!await checkReportExists(report,reportType,reportTypeLabel,libProject)){
}else if(!await checkReportAndDisplay(report,reportType,reportTypeLabel,libProject)){
const message = localize("test.report.does.not.exist.run.test.first", report);
vscode.window.showInformationMessage(message);
}
Expand Down Expand Up @@ -614,16 +613,14 @@ function isWin(): boolean {
}

function getReportFile(path :any,dir :string,filename:string):any{
console.log("inside getReportFile path::"+path+"::dir::"+dir+"::fileName::"+filename);
console.log("::path::"+Path.join(path,"target",dir,filename));
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 checkReportExists(report : any,reportType : string,reportTypeLabel: string,libProject :LibertyProject): Promise<boolean> {
function checkReportAndDisplay(report : any,reportType : string,reportTypeLabel: string,libProject :LibertyProject): Promise<boolean> {
return new Promise((resolve) => {
fs.exists(report, (exists) => {
if(exists){
Expand Down
20 changes: 10 additions & 10 deletions src/test/MavenTestDevModeActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +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 reportPath35 = path.join(utils.getMvnProjectPath(),"target","reports","failsafe.html");
const alternateReportPath = path.join(utils.getMvnProjectPath(),"target","reports","failsafe.html");
let deleteReport = await utils.deleteReports(reportPath);
let deleteReport35 = await utils.deleteReports(reportPath35);
expect (deleteReport||deleteReport35).to.be.true;
let deleteAlternateReport = await utils.deleteReports(alternateReportPath);
expect (deleteReport||deleteAlternateReport).to.be.true;
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 @@ -113,8 +113,8 @@ it('start maven with options from liberty dashboard', async () => {
{
console.log("Server succuessfully started");
let checkFile = await utils.checkIfTestReportExists(reportPath);
let checkFile35 = await utils.checkIfTestReportExists(reportPath35);
expect (checkFile || checkFile35).to.be.true;
let checkAlternateFile = await utils.checkIfTestReportExists(alternateReportPath);
expect (checkFile || checkAlternateFile).to.be.true;
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 @@ -132,10 +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 reportPath35 = path.join(utils.getMvnProjectPath(),"target","reports","failsafe.html");
const alternateReportPath = path.join(utils.getMvnProjectPath(),"target","reports","failsafe.html");
let deleteReport = await utils.deleteReports(reportPath);
let deleteReport35 = await utils.deleteReports(reportPath35);
expect (deleteReport || deleteReport35).to.be.true;
let deleteAlternateReport = await utils.deleteReports(alternateReportPath);
expect (deleteReport || deleteAlternateReport).to.be.true;
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 @@ -147,8 +147,8 @@ it('start maven with history from liberty dashboard', async () => {
{
console.log("Server succuessfully started");
let checkFile = await utils.checkIfTestReportExists(reportPath);
let checkFile35 = await utils.checkIfTestReportExists(reportPath35);
expect (checkFile || checkFile35).to.be.true;
let checkAlternateFile = await utils.checkIfTestReportExists(alternateReportPath);
expect (checkFile || checkAlternateFile).to.be.true;
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 673ac0c

Please sign in to comment.