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

feat: add caching to run failed and longer tests first #1541

Merged
merged 17 commits into from Jul 3, 2022

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Jun 24, 2022

Closes #1532

TODO

  • Tests
  • Clear cache command
  • Sort by file size, if info not provided

@sheremet-va sheremet-va requested a review from antfu June 24, 2022 17:22
@netlify
Copy link

netlify bot commented Jun 24, 2022

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 8444004
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/62c1819f037e2b0008705308
😎 Deploy Preview https://deploy-preview-1541--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@antfu
Copy link
Member

antfu commented Jul 1, 2022

Looks good for the overall direction.

@sheremet-va sheremet-va force-pushed the feat/order-tests-by-duration branch from c1bea1b to 795518c Compare July 2, 2022 06:39
@sheremet-va sheremet-va force-pushed the feat/order-tests-by-duration branch from ae02421 to 553d285 Compare July 2, 2022 07:30
@sheremet-va
Copy link
Member Author

@antfu I did some changes since your last review:

@sheremet-va sheremet-va requested a review from antfu July 2, 2022 07:38
@@ -36,6 +36,10 @@ Useful to run with [`lint-staged`](https://github.com/okonet/lint-staged) or wit
vitest related /src/index.ts /src/hello-world.js
```

### `vitest clearCache`
Copy link
Member

@antfu antfu Jul 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### `vitest clearCache`
### `vitest purge`

I am not a fan of having pascal case in CLI. Maybe purge, WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why purge tho? Don't see any connection to cache. We can do clear-cache, I guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to find a single word to represent it. As for reference, here is what package managers are doing:

npm cache clean --force
yarn cache clean
pnpm store prune

And for Vite: https://vitejs.dev/guide/dep-pre-bundling.html#file-system-cache

/cc @patak-dev in case we are also going to add a clear cache command for Vite, I think we better align the commands

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do vitect clean, and pass cache as an argument. In future we might add option to clear only some specific caches.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to proposed solution. What do you think, @antfu, @patak-dev?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is something you use a lot so it is better if it is a single word

Hardly disagree with using a lot - I don't know why you would even use it in Vitest, only to clear malformed cache maybe.

Also single words only look good, but confuse a lot. What --clean means? What happens when you call it? I want to have cache in the name somewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use --force a lot because ya, I'm debugging Vite cache itself 👀
So I agree with you that normally isn't something that final users will be reaching a lot. I'm fine with --clearCache (maybe good to check how it will look later for --clearCache="parts of it")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe good to check how it will look later

It will look something like this:

vitest run --clearCache results

We use cac's notation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antfu what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove command for now, since I want this feature to be released today. Command will be in another PR.

@sheremet-va sheremet-va enabled auto-merge (squash) July 3, 2022 12:09
@sheremet-va sheremet-va disabled auto-merge July 3, 2022 12:18
@sheremet-va sheremet-va merged commit 9c60757 into vitest-dev:main Jul 3, 2022
@sheremet-va sheremet-va deleted the feat/order-tests-by-duration branch July 3, 2022 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run slowest tests first or provide a way to provide the order of tests
3 participants