Idea: "target set" language for specifying target patterns
- Dominant language
- Rust
- Stars
- 4.4k
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
While talking on Discord about a general idea of "How do I skip some tests that are slow", I came up with an idea I wanted to post here on the bug tracker:
> Here is a crazy idea that maybe isn't feasible but, in Jujutsu and Sapling (and Mercurial) there's a concept of "revision sets" which are a language for selecting commits in the commit graph. So `jj log -r 'mine() ~ description("wip:")'` means "find all my commits, but exclude ones with `wip:` in the description."
>
> What if we had "target sets" which were a similar language for selecting target names from a more general target pattern? For example, `buck2 build '//folder/... ~ label(exact:"slow")` would be an explicit version of "skip all slow tests but run everything else." I actually wonder if this syntax might even be "compile-able" to a buck2 query expression in some way? It seems like it would solve a lot of the same issues.
For example, one thing I like to do is test clean build times for Rust compiles, cargo vs buck. But cargo keeps downloads cached even after a clean, while buck doesn't. So the first thing I do is some monstrosity like `buck2 build $(buck2 uquery "kind('http_archive', deps('//...'))" | grep third-party//)` which is basically saying "Download all `http_archive` files" first and foremost, then you can run the normal build. But it's kind of awkward to write out and probably doesn't work on Windows.
But instead, I could do: `buck2 build 'rule(exact:"http_archive") & cell("third-party") & depOf("//...")'` and it works everywhere.
I actually use this all the time and it would make many forms of automation obsolete if I could more programmatically select target names from a simple language with expressions and operators.
Before getting into the weeds here, would something like this be sensible? I guess it's kind of tricky because there's a question of whether things like `select()` or configurations should be considered. But it feels like a lot of basic examples like the above should be "sort of" easy to translate to a `query` expression, and they would provide a lot of open ended value. Slow tests and particular rules are just one example.
Contributor guide
Assessment
This issue has not been assessed yet.