From 733f29c58c12f204e0bad04aa6cec6d17fbcb21b Mon Sep 17 00:00:00 2001 From: Nicolas Guerrero Date: Wed, 3 Feb 2021 23:36:32 -0500 Subject: [PATCH] Convert script test runner to Deno.test --- .github/workflows/ci.yml | 7 ++----- node/testdata/runner.ts | 39 --------------------------------------- node/testdata/test.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 44 deletions(-) delete mode 100644 node/testdata/runner.ts create mode 100644 node/testdata/test.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 893ddb169e693..24955a75589e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,14 +39,11 @@ jobs: if: matrix.deno == 'canary' run: deno upgrade --canary - - name: Test - run: deno test --unstable --allow-all - - name: Generate Node tests run: deno run --allow-all node/testdata/setup.ts - - name: Test Node - run: deno run --allow-run --allow-read node/testdata/runner.ts + - name: Test + run: deno test --unstable --allow-all lint: runs-on: ubuntu-latest diff --git a/node/testdata/runner.ts b/node/testdata/runner.ts deleted file mode 100644 index 6caedac004547..0000000000000 --- a/node/testdata/runner.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { walk } from "../../fs/walk.ts"; -import { dirname, fromFileUrl } from "../../path/mod.ts"; -import { config, testList } from "./common.ts"; - -/** - * This script will run the test files specified in the configuration file - * - * Each test file will be run independently and wait until completion, if an abnormal - * code for the test is reported, the test suite will fail inmediately - * - * Usage: `deno run --allow-run --allow-read runner.ts` - */ - -const dir = walk(fromFileUrl(new URL(config.suitesFolder, import.meta.url)), { - includeDirs: false, - match: testList, -}); - -for await (const file of dir) { - const process = Deno.run({ - cwd: dirname(fromFileUrl(import.meta.url)), - cmd: [ - "deno", - "run", - "-A", - "--unstable", - "require.ts", - file.path, - ], - }); - - const { code } = await process.status(); - - if (code === 0) { - console.log(`${file.path} ....... OK`); - } else { - Deno.exit(code); - } -} diff --git a/node/testdata/test.ts b/node/testdata/test.ts new file mode 100644 index 0000000000000..16e7dcfcde183 --- /dev/null +++ b/node/testdata/test.ts @@ -0,0 +1,40 @@ +import { walk } from "../../fs/walk.ts"; +import { basename, dirname, fromFileUrl } from "../../path/mod.ts"; +import { assertEquals } from "../../testing/asserts.ts"; +import { config, testList } from "./common.ts"; + +/** + * This script will run the test files specified in the configuration file + * + * Each test file will be run independently and wait until completion, if an abnormal + * code for the test is reported, the test suite will fail inmediately + */ + +const dir = walk(fromFileUrl(new URL(config.suitesFolder, import.meta.url)), { + includeDirs: false, + match: testList, +}); + +for await (const file of dir) { + Deno.test({ + name: `Node test runner: ${basename(file.path)}`, + fn: async () => { + const process = Deno.run({ + cwd: dirname(fromFileUrl(import.meta.url)), + cmd: [ + "deno", + "run", + "-A", + "--unstable", + "require.ts", + file.path, + ], + }); + + const { code } = await process.status(); + process.close(); + + assertEquals(code, 0); + }, + }); +}