Skip to content

Commit 72579ec

Browse files
committed
Be a bit more opinionated with expected shape of results
Check up front if all the keys we need are there, and add an error to the error list if not. If the keys are there, assume they are the right type. We actually don't need the `file` key. There is no reason to use it as a backup for the `relative` key; we should consider the entry broken if there is no `relative` key.
1 parent 5e37bfa commit 72579ec

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

‎tools/misc/build-results-comment.mjs‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,26 @@ function loadResults() {
5353
engines.push(engineKey);
5454

5555
for (const test of data) {
56-
const testPath = test.relative || test.file;
57-
if (!testPath) {
56+
const { relative, scenario, result } = test;
57+
if (!relative || !scenario || !result) {
58+
errors.push(`**${engineKey}**: Unexpected format of array entry in ${file} (${Object.keys(test)})`);
5859
continue;
5960
}
60-
const normalizedPath = testPath.replace(/^test\//, '');
61-
let pathResults = testResults.get(normalizedPath);
61+
let pathResults = testResults.get(relative);
6262
if (!pathResults) {
6363
pathResults = {};
64-
testResults.set(normalizedPath, pathResults);
64+
testResults.set(relative, pathResults);
6565
}
66-
if (test.result) {
67-
const scenario = test.scenario === 'strict mode' ? 'strict' : 'sloppy';
68-
let engineResults = pathResults[engineKey];
69-
if (!engineResults) {
70-
engineResults = {};
71-
pathResults[engineKey] = engineResults;
72-
}
73-
engineResults[scenario] = {
74-
pass: !!test.result.pass,
75-
message: test.result.message,
76-
};
66+
const resultKey = scenario === 'strict mode' ? 'strict' : 'sloppy';
67+
let engineResults = pathResults[engineKey];
68+
if (!engineResults) {
69+
engineResults = {};
70+
pathResults[engineKey] = engineResults;
7771
}
72+
engineResults[resultKey] = {
73+
pass: !!result.pass,
74+
message: result.message,
75+
};
7876
}
7977
}
8078

0 commit comments

Comments
 (0)