Skip to content

[TE-6238] Prepend and trim location prefix when split by selector#575

Draft
nprizal wants to merge 1 commit into
mainfrom
naufan/te-6238/apply-location-prefix-when-split-by-selector
Draft

[TE-6238] Prepend and trim location prefix when split by selector#575
nprizal wants to merge 1 commit into
mainfrom
naufan/te-6238/apply-location-prefix-when-split-by-selector

Conversation

@nprizal

@nprizal nprizal commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

This is a spike for one of the options we're weighing for how location prefix should interact with selector based splitting (see Context). Specifically, it's what bktec needs to look like under the option where test.selector.primary includes the location prefix.

Right now, selector based splitting sends discovered test targets straight to the Test Plan API as raw selectors, with no location prefix applied. If ingestion ends up setting test.selector.primary with the prefix included, our selector won't match what's stored, and the test plan will come back with no historical duration.

This PR makes bktec prepend the location prefix to a selector before sending it, but only when the selector is actually a file path (e.g. Rspec). Some runners use selectors that aren't file paths at all (e.g. Go package names), so we check with os.Stat first and leave those untouched.

I also fixed trimTaskLocationPrefix in run.go, which previously skipped selector-format tests entirely when trimming the prefix from the plan we get back. Now it trims the prefix from test.Value for those too, so the runner gets a selector it can actually use.

Context

We hit this while testing selector based splitting for rspec in buildkite/buildkite (build) and the plan came back with no historical duration.

We're still deciding how ingestion should set test.selector.primary when location prefix is configured: leave the prefix out, or include it. This PR is a spike for what bktec looks like if we go with including it. Wrote up the full problem in this doc if you want more background.

Linear: TE-6238

Testing

Covered by unit tests.

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.

1 participant