Add file check for NUnit XML format before parsing

pull/286/head
Gabriel Le Breton 2024-11-07 22:49:59 -05:00
parent 7386cbef09
commit c43bdc7bed
No known key found for this signature in database
GPG Key ID: F1C2F88E084E4EF1
1 changed files with 5 additions and 0 deletions

View File

@ -23,6 +23,11 @@ const ResultsCheck = {
if (!filepath.endsWith('.xml')) return;
core.info(`Processing file ${filepath}...`);
try {
const content = fs.readFileSync(path.join(artifactsPath, filepath), 'utf8');
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 = await ResultsParser.parseResults(path.join(artifactsPath, filepath));
core.info(fileData.summary);
runs.push(fileData);