Compare commits

..

No commits in common. "ac5c61b9f559d5a2d8726e7516f99d994ad9307b" and "90b20029c9dde21218e2464a1e8958435fd42286" have entirely different histories.

7 changed files with 32 additions and 32 deletions

View File

@ -24,5 +24,5 @@ test.end('verify', async (stats) => {
assert.equal(stats.testFail.length, 0)
})
import { runifmain } from '../index.js'
await runifmain(import.meta, test)
import { runifmain, summaryreporter, errorreporter } from '../index.js'
await runifmain(import.meta, () => test.run(summaryreporter(), errorreporter()))

View File

@ -6,15 +6,9 @@ const isMain = (meta) => {
return path.includes(process.argv[1])
}
import { errorreporter, summaryreporter } from '../index.js'
const runifmain = async (meta, fn, ...args) => {
if (!isMain(meta)) return
if (fn.name === 'runner' && fn.run) {
if (args.length == 0) args.push(summaryreporter(), errorreporter())
await fn.run(...args)
} else {
await fn(...args)
const runifmain = async (meta, fn) => {
if (isMain(meta)) {
await fn()
}
}

View File

@ -22,5 +22,5 @@ test('Diff', () => {
}
})
import { runifmain } from '../index.js'
await runifmain(import.meta, test)
import { runifmain, summaryreporter, errorreporter } from '../index.js'
await runifmain(import.meta, () => test.run(summaryreporter(), errorreporter()))

View File

@ -1,15 +1,11 @@
import { readdir } from 'node:fs/promises'
import { join } from 'node:path'
const walkDir = async function* (dir = '.', exclude = []) {
const walkDir = async function* (dir) {
const files = await readdir(dir, { withFileTypes: true })
for (const file of files) {
if (exclude.includes(file.name)) continue
if (file.isDirectory()) {
yield* walkDir(join(dir, file.name))
} else if (file.isSymbolicLink()) {
yield* walkDir(join(dir, file.name))
} else {
yield join(dir, file.name)
}
@ -38,7 +34,9 @@ const suite = async (folder = '.') => {
const total = totalreporter()
for await (const file of walkDir(folder, ['node_modules', '.git'])) {
for await (const file of walkDir(folder)) {
if (file.includes('node_modules')) continue
if (file.startsWith('.git')) continue
if (!file.endsWith('.test.js')) continue
const module = join(absolutePath, file)

21
package-lock.json generated
View File

@ -1,21 +1,21 @@
{
"name": "metaltest",
"version": "1.4.0",
"lockfileVersion": 3,
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "metaltest",
"version": "1.4.0",
"version": "1.0.0",
"license": "AGPL-3.0-or-later",
"dependencies": {
"chalk": "^5.3.0"
"chalk": "^5.1.2"
}
},
"node_modules/chalk": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
"integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==",
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.1.2.tgz",
"integrity": "sha512-E5CkT4jWURs1Vy5qGJye+XwCkNj7Od3Af7CP6SujMetSMkLs8Do2RWJK5yx1wamHV/op8Rz+9rltjaTQWDnEFQ==",
"engines": {
"node": "^12.17.0 || ^14.13 || >=16.0.0"
},
@ -23,5 +23,12 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
}
},
"dependencies": {
"chalk": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.1.2.tgz",
"integrity": "sha512-E5CkT4jWURs1Vy5qGJye+XwCkNj7Od3Af7CP6SujMetSMkLs8Do2RWJK5yx1wamHV/op8Rz+9rltjaTQWDnEFQ=="
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "metaltest",
"version": "1.4.0",
"version": "1.3.0",
"description": "Clone of baretest with reporting",
"type": "module",
"exports": "./index.js",
@ -14,6 +14,6 @@
"author": "Frédéric Matte <fmatte@gmail.com>",
"license": "AGPL-3.0-or-later",
"dependencies": {
"chalk": "^5.3.0"
"chalk": "^5.1.2"
}
}

View File

@ -1,7 +1,5 @@
import chalk from 'chalk'
const percentage = (dividend, divisor) => (dividend / divisor * 100).toFixed(0)
const totalreporter = () => {
let success = 0, fail = 0, skip = 0
@ -9,7 +7,10 @@ const totalreporter = () => {
success: (test) => { success++ },
fail: (test, e) => { fail++ },
skip: (test) => { skip++ },
msg: () => `${chalk.redBright(`Fail: ${fail}`)} - ${chalk.greenBright(`Sucess: ${success}`)} - ${chalk.blueBright(`Skip: ${skip}`)} - ${chalk.yellowBright(`Ratio: ${percentage(success, success + fail)}%`)}`
msg: () => `${chalk.redBright(`Fail: ${fail}`)}
${chalk.greenBright(`Sucess: ${success}`)}
${chalk.blueBright(`Skip: ${skip}`)}
${chalk.yellowBright(`Ratio ${(success / (success + fail) * 100).toFixed(0)}%`)}`
}
}