mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
Add vitest related to pre-commit with expensive test skipping (#7854)
## Summary This PR improves the pre-commit hook performance by: - Using `vitest related` to run only tests affected by changed files - Adding ability to skip expensive tests (filter tests) during pre-commit - Providing a consistent mechanism for skipping expensive tests ## Changes - Modified `lint-staged.config.mjs` to run `vitest related` with `SKIP_EXPENSIVE_TESTS=true` - Updated `test/filter-tests.ts` to use idiomatic `describe.skipIf()` for conditional test execution - Changed `test-min` script to use `SKIP_EXPENSIVE_TESTS` environment variable instead of `--exclude` - Updated `CLAUDE.md` with documentation about the new test workflow ## Impact - Pre-commit hooks are now much faster as they: - Only run tests related to changed files - Skip 688 expensive filter tests - Use the same skipping mechanism as `npm run test-min` ## Testing - ✅ Verified `vitest related` correctly identifies and runs related tests - ✅ Confirmed filter tests are skipped when `SKIP_EXPENSIVE_TESTS=true` - ✅ Tested that full test suite still runs all tests when env var is not set - ✅ Pre-commit hooks work correctly with the new setup 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -84,6 +84,13 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
- Write platform-specific assertions
|
||||
- Use path-agnostic checks
|
||||
|
||||
### Test Execution with Expensive Test Skipping
|
||||
- The `SKIP_EXPENSIVE_TESTS=true` environment variable skips expensive tests (like filter tests)
|
||||
- Pre-commit hooks use `vitest related` to run only tests related to changed files
|
||||
- Use `npm run test-min` to run tests with expensive tests skipped
|
||||
- Use `npm run test` to run all tests including expensive ones
|
||||
- To mark tests as expensive, use: `describe.skipIf(process.env.SKIP_EXPENSIVE_TESTS === 'true')('Test suite', () => {...})`
|
||||
|
||||
## Compiler Testing Specifics
|
||||
- Mock filesystem operations when testing file I/O
|
||||
- Use `makeFakeCompilerInfo()` for creating test compiler configurations
|
||||
|
||||
Reference in New Issue
Block a user