All JS and Python tests passing.
This commit is contained in:
@@ -4,7 +4,7 @@ import { execSync } from 'node:child_process'
|
||||
import { useDocument } from '@terrace/core'
|
||||
import { createFileReader } from '@terrace/core/readers/node-readline'
|
||||
|
||||
async function loadTests(path) {
|
||||
export async function loadTestMap(path) {
|
||||
const { next, level, head, tail, line, match } = useDocument(createFileReader(path))
|
||||
|
||||
const descriptions = {}
|
||||
@@ -58,6 +58,20 @@ async function loadTests(path) {
|
||||
return descriptions
|
||||
}
|
||||
|
||||
export function defineTests(testMap) {
|
||||
for (const [name, tests] of Object.entries(testMap)) {
|
||||
describe(name, () => {
|
||||
for (const test of tests) {
|
||||
test.packages.forEach(pkg => {
|
||||
it(`${pkg}: ${test.it}`, async () => {
|
||||
expect(await callTest(pkg, test.key, test.input)).to.equal(test.output)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function callTest(pkg, name, input) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const stdout = execSync(`npm run --silent test ${name}`, {
|
||||
@@ -69,17 +83,3 @@ function callTest(pkg, name, input) {
|
||||
resolve(stdout.toString().trim())
|
||||
})
|
||||
}
|
||||
|
||||
const descriptions = await loadTests('./tests.tce')
|
||||
|
||||
for (const [name, tests] of Object.entries(descriptions)) {
|
||||
describe(name, () => {
|
||||
for (const test of tests) {
|
||||
test.packages.forEach(pkg => {
|
||||
it(`${pkg}: ${test.it}`, async () => {
|
||||
expect(await callTest(pkg, test.key, test.input)).to.equal(test.output)
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
3
test/lineData.test.js
Normal file
3
test/lineData.test.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { loadTestMap, defineTests } from './helpers.js'
|
||||
|
||||
defineTests(await loadTestMap('./lineData.test.tce'))
|
||||
Reference in New Issue
Block a user