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

add suites runner and correct skip logic #1

Merged
merged 4 commits into from
Nov 28, 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
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"scripts": {
"lint": "standard",
"lint:fix": "standard --fix",
"unit:template-ts-esm": "node should-test-suite.js unit:ts-esm || cross-env TS_NODE_PROJECT=./templates/app-ts-esm/tsconfig.json FASTIFY_AUTOLOAD_TYPESCRIPT=1 node --test --import tsx/esm templates/app-ts-esm/test/**/*.test.ts",
"unit:cli": "tap \"test/**/*.test.js\" --no-coverage --timeout 400 --jobs 1 --color -R specy",
"unit:templates-without-ts-esm": "npm run unit:cjs && npm run unit:esm && npm run unit:ts-cjs",
"unit:cjs": "node should-test-suite.js unit:cjs || node --test templates/app/test/**/*.test.js",
"unit:esm": "node should-test-suite.js unit:esm || node --test templates/app-esm/test/**/*.test.js",
"unit:ts-cjs": "node should-test-suite.js unit:ts-cjs || node --test --require tsx/cjs templates/app-ts/test/**/*.test.ts",
"pretest": "xcopy /e /k /i . \"..\\node_modules\\fastify-cli\" || rsync -r --exclude=node_modules ./ node_modules/fastify-cli || echo 'this is fine'",
"test": "c8 --clean npm run test:cli-and-typescript && npm run unit:suites",
"unit:cjs": "c8 node suite-runner.js templates/app/test/**/*.test.js",
"unit:esm": "c8 node suite-runner.js templates/app-esm/test/**/*.test.js",
"unit:ts-cjs": "c8 node -r tsx/cjs suite-runner.js templates/app-ts/test/**/*.test.ts",
"unit:ts-esm": "cross-env TS_NODE_PROJECT=./templates/app-ts-esm/tsconfig.json FASTIFY_AUTOLOAD_TYPESCRIPT=1 c8 node -r tsx/cjs --import tsx/esm suite-runner.js templates/app-ts-esm/test/**/*.test.ts",
"unit:suites": "node should-skip-test-suites.js || (npm run unit:cjs && npm run unit:esm && npm run unit:ts-cjs && npm run unit:ts-esm)",
"unit:cli": "tap \"test/**/*.test.js\" --no-coverage --timeout 400 --jobs 1 --color -R specy",
"test:cli-and-typescript": "npm run unit:cli && npm run test:typescript",
"test": "c8 --clean npm run test:cli-and-typescript && npm run unit:templates-without-ts-esm && npm run unit:template-ts-esm",
"test:typescript": "tsd templates/plugin -t ./../../index.d.ts && tsc --project templates/app-ts/tsconfig.json && del-cli templates/app-ts/dist"
},
"keywords": [
Expand Down
7 changes: 7 additions & 0 deletions should-skip-test-suites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const nodeMajorVersion = process.versions.node.split('.').map(x => parseInt(x, 10))[0]
const shouldRunSuites = nodeMajorVersion >= 20
if (!shouldRunSuites) {
console.info(`Skipped templates test suites on node ${nodeMajorVersion}`)
process.exit(0)
}
process.exit(1)
10 changes: 0 additions & 10 deletions should-test-suite.js

This file was deleted.

17 changes: 17 additions & 0 deletions suite-runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { run } = require('node:test')
const { spec } = require('node:test/reporters')
const path = require('path')
const glob = require('glob')

const pattern = process.argv[process.argv.length - 1]

glob(pattern, (err, matches) => {
if (err) {
console.error(err)
process.exit(1)
}
const resolved = matches.map(file => path.resolve(file))
run({ files: resolved })
.compose(spec)
.pipe(process.stdout)
})
Loading