Skip to content

Commit c43bdc7

Browse files
committed
Add file check for NUnit XML format before parsing
1 parent 7386cbe commit c43bdc7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/model/results-check.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ const ResultsCheck = {
2323
if (!filepath.endsWith('.xml')) return;
2424
core.info(`Processing file ${filepath}...`);
2525
try {
26+
const content = fs.readFileSync(path.join(artifactsPath, filepath), 'utf8');
27+
if (!content.includes('<test-results') && !content.includes('<test-run')) {
28+
// noinspection ExceptionCaughtLocallyJS
29+
throw new Error('File does not appear to be a NUnit XML file');
30+
}
2631
const fileData = await ResultsParser.parseResults(path.join(artifactsPath, filepath));
2732
core.info(fileData.summary);
2833
runs.push(fileData);

0 commit comments

Comments
 (0)