Skip to content

Commit

Permalink
Convert script test runner to Deno.test
Browse files Browse the repository at this point in the history
  • Loading branch information
Soremwar committed Feb 4, 2021
1 parent 5a83358 commit a745608
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 44 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 0 additions & 39 deletions node/testdata/runner.ts

This file was deleted.

40 changes: 40 additions & 0 deletions node/testdata/test.ts
Original file line number Diff line number Diff line change
@@ -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);
}
});
}

0 comments on commit a745608

Please sign in to comment.