Skip to content

Commit

Permalink
Merge pull request #122 from galaxyproject/tests_report
Browse files Browse the repository at this point in the history
Add link to test html report in the output
  • Loading branch information
davelopez authored Feb 25, 2021
2 parents 436650b + f1a43bf commit 4180277
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
20 changes: 16 additions & 4 deletions client/src/planemo/testing/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,25 @@ export class PlanemoTestRunner implements ITestRunner {
const testFile = testSuite.file ? testSuite.file : `${planemoConfig.getCwd()}/${testSuiteId}.${Constants.TOOL_DOCUMENT_EXTENSION}`;
try {
const { file: output_json_file, cleanupCallback } = await this.getJsonReportPath(testFile);
const htmlReportFile = this.getTestHtmlReportFilePath(testFile);

const testRunArguments = [
`test`,
`--galaxy_root=${planemoConfig.galaxyRoot()}`,
`--test_output_json=${output_json_file}`,
testFile,
`--galaxy_root`,
`${planemoConfig.galaxyRoot()}`,
`--test_output_json`,
`${output_json_file}`,
`--test_output`,
`${htmlReportFile}`,
`${testFile}`,
]

const testExecution = this.runPlanemoTest(planemoConfig, testRunArguments);

this.testExecutions.set(testSuiteId, testExecution);
await testExecution.complete();

const states = await parseTestStates(output_json_file, testSuite);
const states = await parseTestStates(output_json_file, testSuite, htmlReportFile);

cleanupCallback();

Expand Down Expand Up @@ -98,4 +103,11 @@ export class PlanemoTestRunner implements ITestRunner {
});
});
}

private getTestHtmlReportFilePath(testFile: string): string {
const baseDir = path.dirname(testFile);
const testFileName = path.basename(testFile, Constants.TOOL_DOCUMENT_EXTENSION).replace(".", "");
const reportFile = path.resolve(baseDir, `${testFileName}_test_report.html`);
return reportFile;
}
}
7 changes: 4 additions & 3 deletions client/src/planemo/testing/testsReportParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ interface ITestCaseJobInfo {
tool_stdout: string;
}

export async function parseTestStates(outputJsonFile: string, testSuite: TestSuiteInfo): Promise<TestEvent[]> {
export async function parseTestStates(outputJsonFile: string, testSuite: TestSuiteInfo, htmlReportFile: string): Promise<TestEvent[]> {
const content = await readFile(outputJsonFile);
const parseResult = await JSON.parse(content);
return parseTestResults(parseResult, testSuite);
return parseTestResults(parseResult, testSuite, htmlReportFile);
}

function parseTestResults(parserResult: any, testSuite: TestSuiteInfo): TestEvent[] {
function parseTestResults(parserResult: any, testSuite: TestSuiteInfo, htmlReportFile: string): TestEvent[] {
if (!parserResult) {
return [];
}
Expand All @@ -63,6 +63,7 @@ function parseTestResults(parserResult: any, testSuite: TestSuiteInfo): TestEven
const testInfo = getTestInfo(testCaseResult, testSuite);
const adatedResult = adaptTestResult(testCaseResult, testInfo);
if (adatedResult !== undefined) {
adatedResult.message += `${EOL}${EOL}See full test report: ${htmlReportFile}`;
testResults.push(adatedResult);
}
});
Expand Down

0 comments on commit 4180277

Please sign in to comment.