From 08eb3c9f2322788a8190eaa76bbce87ce6e6083f Mon Sep 17 00:00:00 2001 From: wafuwafu13 Date: Fri, 1 Oct 2021 19:02:47 +0900 Subject: [PATCH] chore(node/_tools/test): Add --only flag to run specific tests --- node/README.md | 17 +++++++++++++++++ node/_tools/test.ts | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/node/README.md b/node/README.md index 57badc6c293e..93c26dbe13c3 100644 --- a/node/README.md +++ b/node/README.md @@ -119,6 +119,23 @@ To run the tests you have set up, do the following: $ deno test --allow-read --allow-run node/_tools/test.ts ``` +If you want to run specific tests in a local environment, add `--only` flag to +the `node/_tools/config.json` as follows: + +```json +... + "tests": { + "parallel": [ + ... + "test-event-emitter-add-listeners.js", + "test-event-emitter-check-listener-leaks.js --only", + "test-event-emitter-invalid-listener.js", + ... + ] + } +... +``` + The test should be passing with the latest deno, so if the test fails, try the following: diff --git a/node/_tools/test.ts b/node/_tools/test.ts index 3885b0cb3c15..25111df29c7b 100644 --- a/node/_tools/test.ts +++ b/node/_tools/test.ts @@ -10,9 +10,13 @@ import { config, testList } from "./common.ts"; * code for the test is reported, the test suite will fail immediately */ +const onlyFlagTestList = config.tests.parallel.filter((filename) => + filename.match("--only") +).map((filename) => new RegExp(filename.replace(/ --only/, ""))); + const dir = walk(fromFileUrl(new URL(config.suitesFolder, import.meta.url)), { includeDirs: false, - match: testList, + match: onlyFlagTestList.length ? onlyFlagTestList : testList, }); const testsFolder = dirname(fromFileUrl(import.meta.url));