Add warning for invalid nunit xml files (#286)
* Allow ResultsParser to fail on non-nunit xml files * yarn build * Add file check for NUnit XML format before parsing * yarn build * Update src/model/results-check.ts Co-authored-by: Koji Hasegawa <hasegawa@nowsprinting.com> --------- Co-authored-by: Koji Hasegawa <hasegawa@nowsprinting.com>pull/282/head^2
parent
05a00ef5ac
commit
0483262850
|
@ -1014,9 +1014,19 @@ const ResultsCheck = {
|
||||||
if (!filepath.endsWith('.xml'))
|
if (!filepath.endsWith('.xml'))
|
||||||
return;
|
return;
|
||||||
core.info(`Processing file ${filepath}...`);
|
core.info(`Processing file ${filepath}...`);
|
||||||
const fileData = yield results_parser_1.default.parseResults(path_1.default.join(artifactsPath, filepath));
|
try {
|
||||||
core.info(fileData.summary);
|
const content = fs.readFileSync(path_1.default.join(artifactsPath, filepath), 'utf8');
|
||||||
runs.push(fileData);
|
if (!content.includes('<test-results') && !content.includes('<test-run')) {
|
||||||
|
// noinspection ExceptionCaughtLocallyJS
|
||||||
|
throw new Error('File does not appear to be a NUnit XML file');
|
||||||
|
}
|
||||||
|
const fileData = yield results_parser_1.default.parseResults(path_1.default.join(artifactsPath, filepath));
|
||||||
|
core.info(fileData.summary);
|
||||||
|
runs.push(fileData);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
core.warning(`Failed to parse ${filepath}: ${error.message}`);
|
||||||
|
}
|
||||||
})));
|
})));
|
||||||
// Combine all results into a single run summary
|
// Combine all results into a single run summary
|
||||||
const runSummary = new results_meta_1.RunMeta(checkName);
|
const runSummary = new results_meta_1.RunMeta(checkName);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -22,9 +22,18 @@ const ResultsCheck = {
|
||||||
files.map(async filepath => {
|
files.map(async filepath => {
|
||||||
if (!filepath.endsWith('.xml')) return;
|
if (!filepath.endsWith('.xml')) return;
|
||||||
core.info(`Processing file ${filepath}...`);
|
core.info(`Processing file ${filepath}...`);
|
||||||
const fileData = await ResultsParser.parseResults(path.join(artifactsPath, filepath));
|
try {
|
||||||
core.info(fileData.summary);
|
const content = fs.readFileSync(path.join(artifactsPath, filepath), 'utf8');
|
||||||
runs.push(fileData);
|
if (!content.includes('<test-run')) {
|
||||||
|
// noinspection ExceptionCaughtLocallyJS
|
||||||
|
throw new Error('File does not appear to be a NUnit XML file');
|
||||||
|
}
|
||||||
|
const fileData = await ResultsParser.parseResults(path.join(artifactsPath, filepath));
|
||||||
|
core.info(fileData.summary);
|
||||||
|
runs.push(fileData);
|
||||||
|
} catch (error: any) {
|
||||||
|
core.warning(`Failed to parse ${filepath}: ${error.message}`);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue