summaryrefslogtreecommitdiff
path: root/tools/lint.js
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-04-20 17:58:14 -0400
committerGitHub <noreply@github.com>2024-04-20 21:58:14 +0000
commitf61e1a9796b551439a0fa266f5630a47974ddc91 (patch)
tree6caf157d37ef82759d81dee59762c2e1bb803ed1 /tools/lint.js
parentf62018e80f6269149784246fdc6b22539b9c0bb8 (diff)
chore: add lint script to ensure no new `itest!` tests (#23475)
Diffstat (limited to 'tools/lint.js')
-rwxr-xr-xtools/lint.js63
1 files changed, 63 insertions, 0 deletions
diff --git a/tools/lint.js b/tools/lint.js
index f48f3e850..3361ef6b8 100755
--- a/tools/lint.js
+++ b/tools/lint.js
@@ -21,6 +21,7 @@ if (js) {
promises.push(dlint());
promises.push(dlintPreferPrimordials());
promises.push(ensureCiYmlUpToDate());
+ promises.push(ensureNoNewITests());
if (rs) {
promises.push(checkCopyright());
@@ -180,3 +181,65 @@ async function ensureCiYmlUpToDate() {
);
}
}
+
+async function ensureNoNewITests() {
+ // Note: Only decrease these numbers. Never increase them!!
+ // This is to help ensure we slowly deprecate these tests and
+ // replace them with spec tests.
+ const iTestCounts = {
+ "bench_tests.rs": 37,
+ "bundle_tests.rs": 12,
+ "cache_tests.rs": 11,
+ "cert_tests.rs": 3,
+ "check_tests.rs": 28,
+ "compile_tests.rs": 0,
+ "coverage_tests.rs": 0,
+ "doc_tests.rs": 17,
+ "eval_tests.rs": 9,
+ "flags_tests.rs": 0,
+ "fmt_tests.rs": 17,
+ "info_tests.rs": 20,
+ "init_tests.rs": 0,
+ "inspector_tests.rs": 0,
+ "install_tests.rs": 0,
+ "jsr_tests.rs": 0,
+ "js_unit_tests.rs": 0,
+ "jupyter_tests.rs": 0,
+ "lint_tests.rs": 24,
+ "lsp_tests.rs": 0,
+ "node_compat_tests.rs": 4,
+ "node_unit_tests.rs": 3,
+ "npm_tests.rs": 98,
+ "pm_tests.rs": 0,
+ "publish_tests.rs": 28,
+ "repl_tests.rs": 0,
+ "run_tests.rs": 381,
+ "shared_library_tests.rs": 0,
+ "task_tests.rs": 30,
+ "test_tests.rs": 80,
+ "upgrade_tests.rs": 0,
+ "vendor_tests.rs": 1,
+ "watcher_tests.rs": 0,
+ "worker_tests.rs": 23,
+ };
+ const integrationDir = join(ROOT_PATH, "tests", "integration");
+ for await (const entry of Deno.readDir(integrationDir)) {
+ if (!entry.name.endsWith("_tests.rs")) {
+ continue;
+ }
+ const fileText = await Deno.readTextFile(join(integrationDir, entry.name));
+ const actualCount = fileText.match(/itest\!/g)?.length ?? 0;
+ const expectedCount = iTestCounts[entry.name] ?? 0;
+ // console.log(`"${entry.name}": ${actualCount},`);
+ if (actualCount > expectedCount) {
+ throw new Error(
+ `New itest added to ${entry.name}! The itest macro is deprecated. Please move this test to ~/tests/specs.`,
+ );
+ } else if (actualCount < expectedCount) {
+ throw new Error(
+ `Thanks for removing an itest in ${entry.name}. ` +
+ `Please update the count in tools/lint.js for this file to ${actualCount}.`,
+ );
+ }
+ }
+}