Update test framework: fix run_tests.py to support all test files, add auto-import-check for test files

This commit is contained in:
qiaoxinjiu
2026-05-09 15:11:30 +08:00
parent eb053a347f
commit eaba8328da
21739 changed files with 2236758 additions and 719 deletions

View File

@@ -0,0 +1,3 @@
// v18.19.0 backported ESM hook execution to a separate thread,
// thus being equivalent to >=v20.
require('./v20-get-esm-exports')

View File

@@ -0,0 +1,31 @@
'use strict'
const getEsmExports = require('../../lib/get-esm-exports.js')
const fs = require('fs')
const assert = require('assert')
const path = require('path')
const fixturePath = path.join(__dirname, '../fixtures/esm-exports.txt')
const fixture = fs.readFileSync(fixturePath, 'utf8')
fixture.split('\n').forEach(line => {
if (!line.includes(' //| ')) return
const [mod, testStr] = line.split(' //| ')
const expectedNames = testStr.split(',').map(x => x.trim())
if (expectedNames[0] === '') {
expectedNames.length = 0
}
const names = Array.from(getEsmExports(mod))
assert.deepEqual(expectedNames, names)
console.log(`${mod}\n ✅ contains exports: ${testStr}`)
})
// // Generate fixture data
// fixture.split('\n').forEach(line => {
// if (!line.includes('export ')) {
// console.log(line)
// return
// }
// const names = getEsmExports(line)
// console.log(line, '//|', names.join(','))
// })