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

Method updateAllowlist

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

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

(summary)

Source from the content-addressed store, hash-verified

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