Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace bash test runner with TypeScript #572

Merged
merged 3 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prebuild": "tsx scripts/rmrf.ts lib dist",
"build": "tsx scripts/build.ts",
"test": "scripts/run_tests.bash",
"test": "tsx scripts/run_tests.ts",
"typecheck": "tsc",
"repl": "tsx"
},
Expand Down
6 changes: 0 additions & 6 deletions scripts/run_tests.bash

This file was deleted.

19 changes: 19 additions & 0 deletions scripts/run_tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { readdirSync } from 'node:fs';
import { join } from 'path';
import { execFileSync } from 'node:child_process';

// TODO: Update with enabling withFileTypes if fixed the feature
//
// Do NOT specify both recursive and withFileTypes as true, entries will be missed in v20.5.1
// - https://github.com/kachick/times_kachick/issues/244
// - https://github.com/nodejs/node/pull/48698
const baseNames = readdirSync('src', { encoding: 'utf-8', recursive: true, withFileTypes: false });

const testPaths = baseNames.flatMap((name) => name.endsWith('.test.ts') ? [join('src', name)] : []);

console.log('Starting to run tests for', testPaths);

execFileSync('node', ['--loader', 'tsx', '--no-warnings', '--test', ...testPaths], {
// preserving color: https://github.com/nodejs/help/issues/2183#issuecomment-532362821
stdio: 'inherit',
});