Skip to content

Commit

Permalink
chore: use tinyglobby instead of fast-glob in Vitest
Browse files Browse the repository at this point in the history
This reverts commit 70baaaa.
  • Loading branch information
benmccann committed Dec 23, 2024
1 parent 61b3016 commit b273876
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 433 deletions.
9 changes: 9 additions & 0 deletions packages/ui/client/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,13 @@ declare global {
// @ts-ignore
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
import('vue')
// @ts-ignore
export type { ViewportSize } from './composables/browser'
import('./composables/browser')
// @ts-ignore
export type { ModuleType, ModuleNode, ModuleLink, ModuleGraph, ModuleGraphController, ModuleGraphConfig, ModuleLabelItem } from './composables/module-graph'
import('./composables/module-graph')
// @ts-ignore
export type { Params } from './composables/params'
import('./composables/params')
}
356 changes: 36 additions & 320 deletions packages/vitest/LICENSE.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@
"cac": "^6.7.14",
"chai-subset": "^1.6.0",
"cli-truncate": "^4.0.0",
"fast-glob": "3.3.2",
"find-up": "^6.3.0",
"flatted": "^3.3.2",
"get-tsconfig": "^4.8.1",
Expand All @@ -202,6 +201,7 @@
"pretty-format": "^29.7.0",
"prompts": "^2.4.2",
"strip-literal": "^2.1.1",
"tinyglobby": "^0.2.10",
"ws": "^8.18.0"
}
}
4 changes: 2 additions & 2 deletions packages/vitest/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { fileURLToPath } from 'node:url'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import nodeResolve from '@rollup/plugin-node-resolve'
import fg from 'fast-glob'
import { dirname, join, normalize, resolve } from 'pathe'
import { defineConfig } from 'rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
import license from 'rollup-plugin-license'
import { globSync } from 'tinyglobby'
import c from 'tinyrainbow'

const require = createRequire(import.meta.url)
Expand Down Expand Up @@ -198,7 +198,7 @@ function licensePlugin() {
preserveSymlinks: false,
}),
)
const [licenseFile] = fg.sync(`${pkgDir}/LICENSE*`, {
const [licenseFile] = globSync(`${pkgDir}/LICENSE*`, {
caseSensitiveMatch: false,
})
if (licenseFile) {
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest/src/node/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import path from 'node:path'
import { deepMerge, nanoid, slash } from '@vitest/utils'
import fg from 'fast-glob'
import mm from 'micromatch'
import { isAbsolute, join, relative } from 'pathe'
import { glob, type GlobOptions } from 'tinyglobby'
import { ViteNodeRunner } from 'vite-node/client'
import { ViteNodeServer } from 'vite-node/server'
import { setup } from '../api/setup'
Expand Down Expand Up @@ -413,13 +413,13 @@ export class TestProject {

/** @internal */
async globFiles(include: string[], exclude: string[], cwd: string) {
const globOptions: fg.Options = {
const globOptions: GlobOptions = {
dot: true,
cwd,
ignore: exclude,
}

const files = await fg(include, globOptions)
const files = await glob(include, globOptions)
// keep the slashes consistent with Vite
// we are not using the pathe here because it normalizes the drive letter on Windows
// and we want to keep it the same as working dir
Expand Down
77 changes: 0 additions & 77 deletions packages/vitest/src/node/workspace/fast-glob-pattern.ts

This file was deleted.

11 changes: 4 additions & 7 deletions packages/vitest/src/node/workspace/resolveWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import { existsSync, promises as fs } from 'node:fs'
import os from 'node:os'
import { limitConcurrency } from '@vitest/runner/utils'
import { deepClone, toArray } from '@vitest/utils'
import fg from 'fast-glob'
import { dirname, relative, resolve } from 'pathe'
import { glob, type GlobOptions, isDynamicPattern } from 'tinyglobby'
import { mergeConfig } from 'vite'
import { configFiles as defaultConfigFiles } from '../../constants'
import { wildcardPatternToRegExp } from '../../utils/base'
import { isTTY } from '../../utils/env'
import { initializeProject, TestProject } from '../project'
import { withLabel } from '../reporters/renderers/utils'
import { isDynamicPattern } from './fast-glob-pattern'

export async function resolveWorkspace(
vitest: Vitest,
Expand Down Expand Up @@ -357,14 +356,12 @@ async function resolveTestProjectConfigs(
}

if (workspaceGlobMatches.length) {
const globOptions: fg.Options = {
const globOptions: GlobOptions = {
absolute: true,
dot: true,
onlyFiles: false,
cwd: vitest.config.root,
markDirectories: true,
// TODO: revert option when we go back to tinyglobby
// expandDirectories: false,
expandDirectories: false,
ignore: [
'**/node_modules/**',
// temporary vite config file
Expand All @@ -374,7 +371,7 @@ async function resolveTestProjectConfigs(
],
}

const workspacesFs = await fg.glob(workspaceGlobMatches, globOptions)
const workspacesFs = await glob(workspaceGlobMatches, globOptions)

await Promise.all(workspacesFs.map(async (path) => {
// directories are allowed with a glob like `packages/*`
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.

40 changes: 20 additions & 20 deletions test/cli/test/__snapshots__/list.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`basic output shows error 1`] = `
"Error: top level error
❯ top-level-error.test.ts:1:7
1| throw new Error('top level error')
| ^
2|
Error: describe error
"Error: describe error
❯ describe-error.test.ts:4:9
2|
3| describe('describe error', () => {
Expand All @@ -16,6 +10,12 @@ Error: describe error
5|
6| it('wont run', () => {
Error: top level error
top-level-error.test.ts:1:7
1| throw new Error('top level error')
| ^
2|
"
`;
Expand Down Expand Up @@ -60,13 +60,7 @@ math.test.ts > failing test
`;
exports[`json output shows error 1`] = `
"Error: top level error
❯ top-level-error.test.ts:1:7
1| throw new Error('top level error')
| ^
2|
Error: describe error
"Error: describe error
❯ describe-error.test.ts:4:9
2|
3| describe('describe error', () => {
Expand All @@ -75,17 +69,17 @@ Error: describe error
5|
6| it('wont run', () => {
"
`;
exports[`json with a file output shows error 1`] = `
"Error: top level error
Error: top level error
top-level-error.test.ts:1:7
1| throw new Error('top level error')
| ^
2|
Error: describe error
"
`;
exports[`json with a file output shows error 1`] = `
"Error: describe error
❯ describe-error.test.ts:4:9
2|
3| describe('describe error', () => {
Expand All @@ -94,5 +88,11 @@ Error: describe error
5|
6| it('wont run', () => {
Error: top level error
top-level-error.test.ts:1:7
1| throw new Error('top level error')
| ^
2|
"
`;

0 comments on commit b273876

Please sign in to comment.