Skip to content

Conversation

@nick96
Copy link

@nick96 nick96 commented Dec 7, 2025

I've been working on setting up a project with buck2 lately and ran into an issue with editor integration (specifically vscode with rust analyser).

The generated runnable doesn't work with buck2 because it hardcodes "buck". It also doesn't respect the --buck2-command flag and passed flags to the rust test binary that the default rust test harness does not understand (e.g. --print-passing-details). Now, the command is generated from the Buck struct so --buck2-command is respected. I've also tweaked the flags that get passed through to map to the default rust test harness, perhaps there should be a way of configuring these flags for custom test harnesses? The rational for each flag is:

  • --exact: we only want to run the one test and have its full name. Since rust allows functions and modules to have the same name in the same namespace, it's possible that a test name is the prefix of another.
  • --no-capture: I'm assuming --print-passing-details used to do something like this?

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 7, 2025
@meta-codesync
Copy link
Contributor

meta-codesync bot commented Dec 7, 2025

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D88587950. (Because this pull request was imported automatically, there will not be any future comments.)

@cormacrelf
Copy link
Contributor

cormacrelf commented Dec 7, 2025

This is good, I like the exact and no-capture. You're running one test so may as well show all output. Note that the previous code is for Meta's internal-only TPX test runner. We don't have that but they still use it and so this code should be different depending on cfg(fbcode_build), like it is in #767, which does a similar thing.

@nick96 nick96 force-pushed the rust-project-custom-buck2-command branch from 8ce66c9 to 67e64ce Compare December 7, 2025 21:13
@nick96
Copy link
Author

nick96 commented Dec 7, 2025

Thanks for the feedback @cormacrelf! I've updated my PR based on it

@Wilfred
Copy link
Contributor

Wilfred commented Dec 9, 2025

@nick96 would you mind running rustfmt on your changes?

The generated runnable hardcodes "buck", rather than respecting the
`--buck2-command` flag. Also, the flags passed to the rust test binary
are not understood by the default rust test harness, they're from meta's
internal test runner (e.g. `--print-passing-details`). Now, the command
is generated from the `Buck` struct so `--buck2-command is respected`.
I've also tweaked the flags that get passed through to map to the
default rust test harness, perhaps there should be a way of configuring
these flags for custom test harnesses? The rational for each flag is:

- `--exact`: we only want to run the one test and have its full name.
  Since rust allows functions and modules to have the same name in the
  same namespace, it's possible that a test name is the prefix of
  another.
- `--no-capture`: to give feedback as soon as possible

If the `fbcode` feature is enabled then the internal test runner flags
are still used. I've kept support for the custom buck2 command in all
cases as I think that's universally useful.
@nick96 nick96 force-pushed the rust-project-custom-buck2-command branch from 67e64ce to aea8399 Compare December 11, 2025 20:23
@nick96
Copy link
Author

nick96 commented Dec 11, 2025

@Wilfred sorry for the delay. I've just pushed with formatting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants