-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(config): deprecate cache.dir
option
#5229
Merged
+162
−34
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c77c545
feat!(config): deprecate `cache.dir` option
fenghan34 bd44d67
docs: update
fenghan34 b42c227
types: revert `cache`
fenghan34 91f5d50
test: update
fenghan34 f156b7e
chore: update cli config
fenghan34 e3341fb
test: update
fenghan34 11456b8
chore: keep subcommands
fenghan34 30e122b
chore: handle `cache.dir`
fenghan34 02b08a0
Merge branch 'main' into fix/result-location
fenghan34 82c5c2a
chore: update
fenghan34 b43a562
Merge branch 'main' into fix/result-location
fenghan34 f831b7a
test: update
fenghan34 4a39b08
chore: update
fenghan34 a7cd849
test: add tests
fenghan34 9cb6ec2
Merge branch 'main' into fix/result-location
fenghan34 1aff021
chore: update
fenghan34 147e6b9
docs: update
fenghan34 f0bab3b
Merge branch 'main' into fix/result-location
fenghan34 8af373b
chore: intercept the `--cache.dir` command option
fenghan34 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { expect, test } from "vitest"; | ||
|
||
test('', () => { | ||
expect(true).toBe(true) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { describe, expect, test } from 'vitest' | ||
import { resolve } from 'pathe' | ||
import { runVitest } from '../../test-utils' | ||
|
||
const root = resolve(__dirname, '../fixtures/cache') | ||
const project = resolve(__dirname, '../') | ||
|
||
test('default', async () => { | ||
const { vitest, stdout, stderr } = await runVitest({ | ||
root, | ||
include: ['*.test.ts'], | ||
}) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toBe('') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(project, 'node_modules/.vite/vitest/results.json') | ||
expect(cachePath).toMatch(path) | ||
}) | ||
|
||
test('use cache.dir', async () => { | ||
const { vitest, stdout, stderr } = await runVitest( | ||
{ | ||
root, | ||
include: ['*.test.ts'], | ||
cache: { | ||
dir: 'node_modules/.vitest-custom', | ||
}, | ||
}, | ||
) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toContain('"cache.dir" is deprecated') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(root, 'node_modules/.vitest-custom/results.json') | ||
expect(cachePath).toMatch(path) | ||
}) | ||
|
||
test('use cacheDir', async () => { | ||
const { vitest, stdout, stderr } = await runVitest( | ||
{ | ||
root, | ||
include: ['*.test.ts'], | ||
}, | ||
[], | ||
'test', | ||
{ cacheDir: 'node_modules/.vite-custom' }, | ||
) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toBe('') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(root, 'node_modules/.vite-custom/vitest/results.json') | ||
expect(cachePath).toMatch(path) | ||
}) | ||
|
||
describe('with optimizer enabled', () => { | ||
const deps = { | ||
optimizer: { | ||
web: { | ||
enabled: true, | ||
}, | ||
}, | ||
} | ||
|
||
test('default', async () => { | ||
const { vitest, stdout, stderr } = await runVitest({ | ||
root, | ||
include: ['*.test.ts'], | ||
deps, | ||
}) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toBe('') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(project, 'node_modules/.vite/vitest/results.json') | ||
expect(cachePath).toBe(path) | ||
}) | ||
|
||
test('use cache.dir', async () => { | ||
const { vitest, stdout, stderr } = await runVitest( | ||
{ | ||
root, | ||
include: ['*.test.ts'], | ||
deps, | ||
cache: { | ||
dir: 'node_modules/.vitest-custom', | ||
}, | ||
}, | ||
) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toContain('"cache.dir" is deprecated') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(root, 'node_modules/.vitest-custom/results.json') | ||
expect(cachePath).toBe(path) | ||
}) | ||
|
||
test('use cacheDir', async () => { | ||
const { vitest, stdout, stderr } = await runVitest( | ||
{ | ||
root, | ||
include: ['*.test.ts'], | ||
deps, | ||
}, | ||
[], | ||
'test', | ||
{ cacheDir: 'node_modules/.vite-custom' }, | ||
) | ||
|
||
expect(stdout).toContain('✓ basic.test.ts >') | ||
expect(stderr).toBe('') | ||
|
||
const cachePath = vitest!.cache.results.getCachePath() | ||
const path = resolve(root, 'node_modules/.vite-custom/vitest/results.json') | ||
expect(cachePath).toBe(path) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better to add a handler that throws an error? I think CLI will still propagate the value even if it's not defined in a schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I noticed that, I'll update it later