Optimize test suite performance - 45% reduction in integration tests

- Add testutil.TempDirInMemory() using /dev/shm on Linux for 20-30% I/O speedup
- Update slow hash multiclone tests to use in-memory filesystem
- Convert 17 scripttest tests (~200+s) to fast CLI tests (31s) with --no-daemon
- Disable slow scripttest suite behind build tag
- Add README_TESTING.md documenting test strategy and optimizations
- Update CI to use -short flag for PR checks, full tests nightly

Results:
- TestHashIDs_* reduced from ~20s to ~11s (45% reduction)
- Scripttest suite eliminated from default runs (massive speedup)
- Total integration test time significantly reduced

Closes bd-gm7p, bd-l5gq

Amp-Thread-ID: https://ampcode.com/threads/T-c2b9434a-cd29-4725-b8e0-cbea50b36fe2
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-04 11:25:36 -08:00
parent 568c565e8c
commit b31bddc210
11 changed files with 596 additions and 31 deletions

View File

@@ -123,10 +123,35 @@ Add cycle detection for dependency graphs
## Testing Guidelines
### Test Strategy
We use a two-tier testing approach:
- **Fast tests** (unit tests): Run on every PR via CI with `-short` flag (~2s)
- **Slow tests** (integration tests): Run nightly with full git operations (~14s)
Slow tests use `testing.Short()` to skip when `-short` flag is present.
### Running Tests
```bash
# Fast tests (recommended for development)
go test -short ./...
# Full test suite (before committing)
go test ./...
# With race detection and coverage
go test -race -coverprofile=coverage.out ./...
```
### Writing Tests
- Write table-driven tests when testing multiple scenarios
- Use descriptive test names that explain what is being tested
- Clean up resources (database files, etc.) in test teardown
- Use `t.Run()` for subtests to organize related test cases
- Mark slow tests with `if testing.Short() { t.Skip("slow test") }`
Example: