From e498bee10f0123bb208baa228ce6417542a2c3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 17 Jun 2020 15:32:46 -0400 Subject: [PATCH] replace whitelist by allowlist in parser-tests (#11727) --- Makefile | 12 ++--- .../flow/{whitelist.txt => allowlist.txt} | 0 scripts/parser-tests/flow/index.js | 4 +- .../test262/{whitelist.txt => allowlist.txt} | 0 scripts/parser-tests/test262/index.js | 4 +- .../{whitelist.txt => allowlist.txt} | 0 scripts/parser-tests/typescript/index.js | 4 +- .../parser-tests/utils/parser-test-runner.js | 52 +++++++++---------- 8 files changed, 38 insertions(+), 38 deletions(-) rename scripts/parser-tests/flow/{whitelist.txt => allowlist.txt} (100%) rename scripts/parser-tests/test262/{whitelist.txt => allowlist.txt} (100%) rename scripts/parser-tests/typescript/{whitelist.txt => allowlist.txt} (100%) diff --git a/Makefile b/Makefile index 1a04975abbe3..d635783bae32 100644 --- a/Makefile +++ b/Makefile @@ -172,8 +172,8 @@ test-flow: test-flow-ci: build-bundle-ci bootstrap-flow $(MAKE) test-flow -test-flow-update-whitelist: - $(NODE) scripts/parser-tests/flow --update-whitelist +test-flow-update-allowlist: + $(NODE) scripts/parser-tests/flow --update-allowlist bootstrap-typescript: rm -rf ./build/typescript @@ -187,8 +187,8 @@ test-typescript: test-typescript-ci: build-bundle-ci bootstrap-typescript $(MAKE) test-typescript -test-typescript-update-whitelist: - $(NODE) scripts/parser-tests/typescript --update-whitelist +test-typescript-update-allowlist: + $(NODE) scripts/parser-tests/typescript --update-allowlist bootstrap-test262: rm -rf build/test262 @@ -202,8 +202,8 @@ test-test262: test-test262-ci: build-bundle-ci bootstrap-test262 $(MAKE) test-test262 -test-test262-update-whitelist: - $(NODE) scripts/parser-tests/test262 --update-whitelist +test-test262-update-allowlist: + $(NODE) scripts/parser-tests/test262 --update-allowlist # Does not work on Windows clone-license: diff --git a/scripts/parser-tests/flow/whitelist.txt b/scripts/parser-tests/flow/allowlist.txt similarity index 100% rename from scripts/parser-tests/flow/whitelist.txt rename to scripts/parser-tests/flow/allowlist.txt diff --git a/scripts/parser-tests/flow/index.js b/scripts/parser-tests/flow/index.js index 1a18471ded03..af60022d7b0c 100644 --- a/scripts/parser-tests/flow/index.js +++ b/scripts/parser-tests/flow/index.js @@ -89,8 +89,8 @@ async function* loadTests(root) { const runner = new TestRunner({ testDir: path.join(__dirname, "../../../build/flow/src/parser/test/flow"), - whitelist: path.join(__dirname, "whitelist.txt"), - shouldUpdate: process.argv.includes("--update-whitelist"), + allowlist: path.join(__dirname, "allowlist.txt"), + shouldUpdate: process.argv.includes("--update-allowlist"), async *getTests() { for await (const test of loadTests(this.testDir)) { diff --git a/scripts/parser-tests/test262/whitelist.txt b/scripts/parser-tests/test262/allowlist.txt similarity index 100% rename from scripts/parser-tests/test262/whitelist.txt rename to scripts/parser-tests/test262/allowlist.txt diff --git a/scripts/parser-tests/test262/index.js b/scripts/parser-tests/test262/index.js index 07766b230f9f..43740820150a 100644 --- a/scripts/parser-tests/test262/index.js +++ b/scripts/parser-tests/test262/index.js @@ -148,9 +148,9 @@ function* getPlugins(features) { const runner = new TestRunner({ testDir: path.join(__dirname, "../../../build/test262"), - whitelist: path.join(__dirname, "whitelist.txt"), + allowlist: path.join(__dirname, "allowlist.txt"), logInterval: 500, - shouldUpdate: process.argv.includes("--update-whitelist"), + shouldUpdate: process.argv.includes("--update-allowlist"), async *getTests() { const stream = new TestStream(this.testDir, { diff --git a/scripts/parser-tests/typescript/whitelist.txt b/scripts/parser-tests/typescript/allowlist.txt similarity index 100% rename from scripts/parser-tests/typescript/whitelist.txt rename to scripts/parser-tests/typescript/allowlist.txt diff --git a/scripts/parser-tests/typescript/index.js b/scripts/parser-tests/typescript/index.js index 5e3e4b2a9d63..36bd057cc947 100644 --- a/scripts/parser-tests/typescript/index.js +++ b/scripts/parser-tests/typescript/index.js @@ -45,9 +45,9 @@ async function baselineContainsParserErrorCodes(testName) { const runner = new TestRunner({ testDir: path.join(TSTestsPath, "./cases/compiler"), - whitelist: path.join(__dirname, "whitelist.txt"), + allowlist: path.join(__dirname, "allowlist.txt"), logInterval: 50, - shouldUpdate: process.argv.includes("--update-whitelist"), + shouldUpdate: process.argv.includes("--update-allowlist"), async *getTests() { for await (const test of loadTests(this.testDir)) { diff --git a/scripts/parser-tests/utils/parser-test-runner.js b/scripts/parser-tests/utils/parser-test-runner.js index 3a7cc1903feb..61b3ad16ef62 100644 --- a/scripts/parser-tests/utils/parser-test-runner.js +++ b/scripts/parser-tests/utils/parser-test-runner.js @@ -9,14 +9,14 @@ const dot = chalk.gray("."); class TestRunner { constructor({ testDir, - whitelist, + allowlist, logInterval = 1, shouldUpdate, getTests, parse = this.parse, }) { this.testDir = testDir; - this.whitelist = whitelist; + this.allowlist = allowlist; this.logInterval = logInterval; this.shouldUpdate = shouldUpdate; this.getTests = getTests; @@ -24,7 +24,7 @@ class TestRunner { } async run() { - const whitelistP = this.getWhitelist(); + const allowlistP = this.getAllowlist(); console.log(`Now running tests...`); @@ -35,7 +35,7 @@ class TestRunner { } process.stdout.write("\n"); - const summary = this.interpret(results, await whitelistP); + const summary = this.interpret(results, await allowlistP); await this.output(summary); } @@ -66,8 +66,8 @@ class TestRunner { }); } - async getWhitelist() { - const contents = await fs.readFile(this.whitelist, "utf-8"); + async getAllowlist() { + const contents = await fs.readFile(this.allowlist, "utf-8"); const table = new Set(); for (const line of contents.split("\n")) { @@ -78,8 +78,8 @@ class TestRunner { return table; } - async updateWhitelist(summary) { - const contents = await fs.readFile(this.whitelist, "utf-8"); + async updateAllowlist(summary) { + const contents = await fs.readFile(this.allowlist, "utf-8"); const toRemove = summary.disallowed.success .concat(summary.disallowed.failure) @@ -99,10 +99,10 @@ class TestRunner { updated.sort(); - await fs.writeFile(this.whitelist, updated.join("\n") + "\n", "utf8"); + await fs.writeFile(this.allowlist, updated.join("\n") + "\n", "utf8"); } - interpret(results, whitelist) { + interpret(results, allowlist) { const summary = { passed: true, allowed: { @@ -123,24 +123,24 @@ class TestRunner { results.forEach(function (result) { let classification, isAllowed; - const inWhitelist = whitelist.has(result.id); - whitelist.delete(result.id); + const inAllowlist = allowlist.has(result.id); + allowlist.delete(result.id); if (!result.expectedError) { if (!result.actualError) { classification = "success"; - isAllowed = !inWhitelist; + isAllowed = !inAllowlist; } else { classification = "falseNegative"; - isAllowed = inWhitelist; + isAllowed = inAllowlist; } } else { if (!result.actualError) { classification = "falsePositive"; - isAllowed = inWhitelist; + isAllowed = inAllowlist; } else { classification = "failure"; - isAllowed = !inWhitelist; + isAllowed = !inAllowlist; } } @@ -150,7 +150,7 @@ class TestRunner { ); }); - summary.unrecognized = Array.from(whitelist); + summary.unrecognized = Array.from(allowlist); summary.passed = !!summary.passed && summary.unrecognized.length === 0; return summary; @@ -163,10 +163,10 @@ class TestRunner { " invalid programs produced a parsing error", summary.allowed.falsePositive.length + " invalid programs did not produce a parsing error" + - " (and allowed by the whitelist file)", + " (and allowed by the allowlist file)", summary.allowed.falseNegative.length + " valid programs produced a parsing error" + - " (and allowed by the whitelist file)", + " (and allowed by the allowlist file)", ]; const badnews = []; const badnewsDetails = []; @@ -176,29 +176,29 @@ class TestRunner { tests: summary.disallowed.success, label: "valid programs parsed without error" + - " (in violation of the whitelist file)", + " (in violation of the allowlist file)", }, { tests: summary.disallowed.failure, label: "invalid programs produced a parsing error" + - " (in violation of the whitelist file)", + " (in violation of the allowlist file)", }, { tests: summary.disallowed.falsePositive, label: "invalid programs did not produce a parsing error" + - " (without a corresponding entry in the whitelist file)", + " (without a corresponding entry in the allowlist file)", }, { tests: summary.disallowed.falseNegative, label: "valid programs produced a parsing error" + - " (without a corresponding entry in the whitelist file)", + " (without a corresponding entry in the allowlist file)", }, { tests: summary.unrecognized, - label: "non-existent programs specified in the whitelist file", + label: "non-existent programs specified in the allowlist file", }, ].forEach(function ({ tests, label }) { if (!tests.length) { @@ -225,9 +225,9 @@ class TestRunner { } if (this.shouldUpdate) { - await this.updateWhitelist(summary); + await this.updateAllowlist(summary); console.log(""); - console.log("Whitelist file updated."); + console.log("Allowlist file updated."); } else { process.exitCode = summary.passed ? 0 : 1; }