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

fix: only consider cwd when using glob (fix #3802) #3949

Merged
merged 5 commits into from Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -27,3 +27,4 @@ docs/public/user-avatars
docs/public/sponsors
.eslintcache
docs/.vitepress/cache/
!test/cwd/**/.cache
4 changes: 2 additions & 2 deletions packages/vitest/src/node/workspace.ts
Expand Up @@ -145,13 +145,13 @@ export class WorkspaceProject {

async globFiles(include: string[], exclude: string[], cwd: string) {
const globOptions: fg.Options = {
absolute: true,
dot: true,
cwd,
ignore: exclude,
}

return fg(include, globOptions)
const files = await fg(include, globOptions)
return files.map(file => resolve(cwd, file))
}

async isTargetFile(id: string, source?: string): Promise<boolean> {
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

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

5 changes: 5 additions & 0 deletions test/cwd/.cache/projects/test/.cache/should-not-run.test.ts
@@ -0,0 +1,5 @@
import { expect, test } from 'vitest'

test('should not run', () => {
expect(1).toBe(2)
})
5 changes: 5 additions & 0 deletions test/cwd/.cache/projects/test/should-run.test.ts
@@ -0,0 +1,5 @@
import { expect, test } from 'vitest'

test('should run', () => {
expect(1).toBe(1)
})
10 changes: 10 additions & 0 deletions test/cwd/package.json
@@ -0,0 +1,10 @@
{
"name": "@vitest/test-cwd",
"private": true,
"scripts": {
"test": "cd \".cache/projects/test\" && vitest run"
},
"devDependencies": {
"vitest": "workspace:*"
}
}
3 changes: 3 additions & 0 deletions test/cwd/vitest.config.ts
@@ -0,0 +1,3 @@
import { defineConfig } from 'vitest/config'

export default defineConfig({})