MCPcopy Create free account
hub / github.com/babel/babel / updateAllowlist

Method updateAllowlist

scripts/parser-tests/utils/parser-test-runner.js:115–192  ·  view source on GitHub ↗

* Update the allowlist based on the test results. * @param {Summary} summary

(summary)

Source from the content-addressed store, hash-verified

113 * @param {Summary} summary
114 */
115 async updateAllowlist(summary) {
116 const contents = await fs.readFile(this.allowlist, "utf-8");
117
118 const toRemove = new Set(
119 summary.disallowed.success
120 .concat(summary.disallowed.failure)
121 .map(test => test.id)
122 .concat(summary.unrecognized)
123 );
124
125 const allowedFalsePositiveIds = new Set(
126 summary.allowed.falsePositive.map(test => test.id)
127 );
128
129 let invalidWithoutError = [];
130 let validWithError = [];
131
132 for (const line of contents.split("\n")) {
133 const testId = TestRunner.getTestIdFromAllowlistLine(line);
134 if (testId && !toRemove.has(testId)) {
135 if (allowedFalsePositiveIds.has(testId)) {
136 invalidWithoutError.push(line);
137 } else {
138 validWithError.push(line);
139 }
140 }
141 }
142
143 const relativeFileLinkBase = path.relative(
144 path.dirname(this.allowlist),
145 this.fileLinkBase
146 );
147 invalidWithoutError = invalidWithoutError.concat(
148 summary.disallowed.falsePositive.map(test =>
149 TestRunner.createAllowlistEntry(test, relativeFileLinkBase)
150 )
151 );
152 validWithError = validWithError.concat(
153 summary.disallowed.falseNegative.map(test =>
154 TestRunner.createAllowlistEntry(test, relativeFileLinkBase)
155 )
156 );
157
158 invalidWithoutError.sort();
159 validWithError.sort();
160
161 const errorsMap = new Map();
162 summary.allowed.falseNegative
163 .concat(summary.disallowed.falseNegative)
164 .forEach(test => {
165 errorsMap.set(test.id, test.actualErrorObject);
166 });
167
168 const updated = [
169 `# Allowlist for \`${path.relative(process.cwd(), this.testDir)}\`\n\n`,
170 `> [!NOTE]`,
171 `> This file is automatically generated by \`utils/parser-test-runner\`. Only single-line comments after the list item will be preserved.`,
172 "\n",

Callers 1

outputMethod · 0.95

Calls 7

mapMethod · 0.80
createAllowlistEntryMethod · 0.80
setMethod · 0.65
concatMethod · 0.45
hasMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected