From d6d3bd0ac13b9d3137218e6a8f1e242ce8b79b03 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 10 Nov 2023 15:41:35 -0300 Subject: tests/js/: Run the files directly Instead of dynamically `import()`ing them in `tests/runner.js`, make each test file instead load `tests/runner.js` and run its own tests. --- Makefile | 2 +- tests/js/utils.js | 7 +++++-- tests/runner.js | 19 +++++-------------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 2ca99c4..200253a 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ src/index.js: .SUFFIXES: .js .js-t tests.js-t = $(tests.js:.js=.js-t) $(tests.js-t): - node tests/runner.js $*.js + node $*.js check-t: $(tests.js-t) diff --git a/tests/js/utils.js b/tests/js/utils.js index 523352a..b86d8c2 100644 --- a/tests/js/utils.js +++ b/tests/js/utils.js @@ -1,4 +1,5 @@ -import { eq, keys } from "../../src/utils.js"; +const { runTests } = require("../runner.js"); +const { eq, keys } = require("../../src/utils.js"); const test_eq = t => { t.start("eq()"); @@ -121,7 +122,9 @@ const test_keys = t => { }); }; -export const tests = [ +const tests = [ test_eq, test_keys, ]; + +runTests(tests); diff --git a/tests/runner.js b/tests/runner.js index 2e4e2ce..ca0c183 100644 --- a/tests/runner.js +++ b/tests/runner.js @@ -1,5 +1,4 @@ -import { getExit, ARGV } from "../src/compat.js"; -import { eq } from "../src/utils.js"; +const { eq } = require("../src/utils.js"); class AssertionError extends Error {} @@ -37,20 +36,12 @@ const t = { }, }; -const main = async () => { - const { tests } = await import(`../${ARGV[1]}`); +const runTests = async tests => { for (const testFn of tests) { await testFn(t); } }; - -getExit().then(async exit => { - try { - await main(); - exit(0); - } catch (e) { - console.error(e); - exit(1); - } -}); +module.exports = { + runTests, +}; -- cgit v1.2.3