Skip to content

Conversation

@vinistock
Copy link
Member

@vinistock vinistock commented Feb 12, 2025

Motivation

I noticed something with #3180. We can only accurately linearize ancestors for test files if we index files under the test directories that aren't tests, but support implementations.

For example, in our own codebase, we have lib/ruby_indexer/test/test_case.rb, which is not a test, but implements the parent class for all tests in the indexer. If we never index that parent class, it's impossible to linearize the ancestors of any of the tests and we can't discover them properly.

Implementation

I propose we start indexing non test files inside the test directory. In addition to allowing our improved test functionality to work, users often refer to these support declarations when writing the tests themselves.

I also simplified the code, which was hard to follow, while still trying to maintain the original performance gains applied by recent changes.

One small thing is that I couldn't think of a decent way to not exclude test_case and test_helper from indexing, since both of them are common names that may declare test parent classes and match our file exclusion glob. I created a special case to handle them.

I benchmarked this and it makes no substantial difference in indexing time in Core.

Automated Tests

Added a test verifying the behaviour changes.

Copy link
Member Author


How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vinistock vinistock added server This pull request should be included in the server gem's release notes other Changes that aren't bugfixes, enhancements or breaking changes labels Feb 12, 2025 — with Graphite App
@vinistock vinistock self-assigned this Feb 12, 2025
@vinistock vinistock marked this pull request as ready for review February 12, 2025 21:38
@vinistock vinistock requested a review from a team as a code owner February 12, 2025 21:38
@vinistock vinistock force-pushed the 02-12-ensure_we_index_non_test_files_under_test_directories branch 6 times, most recently from 0e44b1d to af8bce2 Compare February 14, 2025 18:06
@vinistock vinistock force-pushed the 02-12-ensure_we_index_non_test_files_under_test_directories branch from af8bce2 to d296f6c Compare February 24, 2025 14:46
@vinistock vinistock added the graphite-merge Ship this PR using Graphite's merge queue label Feb 24, 2025
Copy link
Member Author

vinistock commented Feb 24, 2025

Merge activity

  • Feb 24, 9:47 AM EST: The merge label 'graphite-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Feb 24, 10:16 AM EST: A user added this pull request to the Graphite merge queue.
  • Feb 24, 10:45 AM EST: A user merged this pull request with the Graphite merge queue.

### Motivation

I noticed something with #3180. We can only accurately linearize ancestors for test files if we index files under the test directories that aren't tests, but support implementations.

For example, in our own codebase, we have `lib/ruby_indexer/test/test_case.rb`, which is not a test, but implements the parent class for all tests in the indexer. If we never index that parent class, it's impossible to linearize the ancestors of any of the tests and we can't discover them properly.

### Implementation

I propose we start indexing non test files inside the test directory. In addition to allowing our improved test functionality to work, users often refer to these support declarations when writing the tests themselves.

I also simplified the code, which was hard to follow, while still trying to maintain the original performance gains applied by recent changes.

One small thing is that I couldn't think of a decent way to not exclude `test_case` and `test_helper` from indexing, since both of them are common names that may declare test parent classes and match our file exclusion glob. I created a special case to handle them.

I benchmarked this and it makes no substantial difference in indexing time in Core.

### Automated Tests

Added a test verifying the behaviour changes.
@graphite-app graphite-app bot force-pushed the 02-12-ensure_we_index_non_test_files_under_test_directories branch from d296f6c to e458a40 Compare February 24, 2025 15:16
@graphite-app graphite-app bot merged commit e458a40 into main Feb 24, 2025
44 checks passed
@graphite-app graphite-app bot deleted the 02-12-ensure_we_index_non_test_files_under_test_directories branch February 24, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

graphite-merge Ship this PR using Graphite's merge queue other Changes that aren't bugfixes, enhancements or breaking changes server This pull request should be included in the server gem's release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants