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

chore(test): pre-import test config files byimport.meta.glob #685

Merged
merged 5 commits into from Mar 28, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/rolldown/package.json
Expand Up @@ -80,8 +80,8 @@
"rollup": "^4.12.1",
"type-fest": "^4.12.0",
"unbuild": "^2.0.0",
"vitest": "^1.3.1",
"fast-glob": "^3.3.2"
"vite": "^5.1.5",
"vitest": "^1.3.1"
},
"optionalDependencies": {
"@rolldown/binding-darwin-arm64": "workspace:*",
Expand Down
28 changes: 9 additions & 19 deletions packages/rolldown/tests/fixture.test.ts
Expand Up @@ -2,32 +2,22 @@ import { test } from 'vitest'
import type { TestConfig } from './src/types'
import { InputOptions, OutputOptions, rolldown } from 'rolldown'
import nodePath from 'node:path'
import * as fastGlob from 'fast-glob'
import { loadTestConfig } from '@tests/utils'

main()

function main() {
const fixturesPath = nodePath.join(__dirname, 'fixtures')
const testConfigPaths = fastGlob.sync('fixtures/**/_config.ts', {
absolute: true,
cwd: __dirname,
})
for (const testConfigPath of testConfigPaths) {
const dirPath = nodePath.relative(
fixturesPath,
nodePath.dirname(testConfigPath),
)
test(dirPath, async (ctx) => {
const testConfig = await loadTestConfig(testConfigPath)
if (testConfig.skip) {
ctx.skip()
return
}
const testConfigPaths = import.meta.glob<TestConfig>(
'./fixtures/**/_config.ts',
{ import: 'default', eager: true },
)
for (const [testConfigPath, testConfig] of Object.entries(testConfigPaths)) {
const dirPath = nodePath.dirname(testConfigPath)
const testName = dirPath.replace('./fixtures/', '')

test.skipIf(testConfig.skip)(testName, async () => {
try {
const output = await compileFixture(
nodePath.dirname(testConfigPath),
nodePath.join(import.meta.dirname, dirPath),
testConfig,
)
if (testConfig.afterTest) {
Expand Down
5 changes: 4 additions & 1 deletion packages/rolldown/tsconfig.json
Expand Up @@ -42,7 +42,10 @@
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
"types": [
"node",
"vite/client"
] /* Specify type package names to be included without being referenced in a source file. */,
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.