Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rmarescu
Copy link
Member

@rmarescu rmarescu commented Feb 22, 2025

  • Replace monolithic cache with per-test file system
  • Cache moved to .shortest/cache
  • Add TestCache to manage caching per-test
  • Add cache clean-up utilities
  • Automatic purge of legacy .shortest/cache.json
  • New CLI command shortest cache clear [--force-purge]

CleanShot 2025-02-21 at 22 49 45@2x

Why

  • Part of Improve caching #287
  • Better isolation between tests
  • Prepares the caching system to support running tests in parallel

@rmarescu rmarescu self-assigned this Feb 22, 2025
@vercel
Copy link

vercel bot commented Feb 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
shortest ⬜️ Ignored (Inspect) Visit Preview Feb 22, 2025 6:41am

@rmarescu rmarescu force-pushed the rmarescu/test-cache branch from e764a44 to f94262d Compare February 22, 2025 01:31
@rmarescu rmarescu changed the title refactor: reorganize cache implementation feat: generate one cache file per test Feb 22, 2025
@rmarescu rmarescu added this to the v0.4.4 milestone Feb 22, 2025
@rmarescu rmarescu marked this pull request as ready for review February 22, 2025 06:42
this.client = createProvider(getConfig().ai);
this.browserTool = browserTool;
this.cache = cache;
this.testCache = new TestCache(test);
Copy link
Member Author

Choose a reason for hiding this comment

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

Not ideal to be initialized here. I think there should be a TestCase instance for each test, that can be passed around (instead of TestFunction). The cache could be linked to that.

(I've tried, but the diff of the PR got too big, so decided to leave it out)

*
* @private
*/
private addToPendingCache(cacheStep: CacheStep) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the responsibility of the caching system, rather than AIClient's.

Copy link
Member Author

Choose a reason for hiding this comment

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

Legacy one-file caching system.

try {
const cacheEntry: CacheEntry = {
test: {
name: this.test.name,
Copy link
Member Author

Choose a reason for hiding this comment

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

Extra metadata to help identify the test associated.

const cacheEntry: CacheEntry = {
test: {
name: this.test.name,
filePath: this.test.filePath,
Copy link
Member Author

Choose a reason for hiding this comment

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

This seems to be empty all the time. Can be fixed in a separate PR.

this.reporter.onRunEnd();

if (this.exitOnSuccess && this.reporter.allTestsPassed()) {
process.exit(0);
Copy link
Member Author

Choose a reason for hiding this comment

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

Should not be TestRunner's responsibility to call process, as that short-circuits the logic in src/bin.ts, which prevents finally block to be executed.

this.log.setGroup("💾");

const cachedTest = await this.cache.get(test);
const testCache = new TestCache(test);
Copy link
Member Author

Choose a reason for hiding this comment

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

A future PR can simplify the logic, so that TestCache for a given test is initialized in a single location.

@rmarescu rmarescu merged commit 8ffe125 into main Feb 22, 2025
6 checks passed
@rmarescu rmarescu deleted the rmarescu/test-cache branch February 22, 2025 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants