-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create "suggested tests" tool in rustbuild
#106249
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for starting on this! It looks like this is just the scaffolding so far - adding a new subcommand seems reasonable, but I would ideally like this to be a separate tool, not part of bootstrap, so that the compile times are better.
Does that make sense, do you know how to get started with the suggestions part of it?
Ok, just a few things for clarification:
Thanks for your help. EDIT: yeah, this is just scaffolding, just a rough idea. Also, I have started working on suggestions, it provides them to you based on modified files that match a glob (obviously more suggestions need to be added but that can be done over time)? |
See how e.g.
It means you have to rebuild rustbuild every time you change the suggestions, i.e. you have to recompile those massive other files. If you put it in a separate tool, you only have to recompile that tool itself, which makes it faster to iterate. I'm not sure what you mean by a |
Ok, moving the tool now makes a lot of sense, do you think I should put it in Thanks again for your patience. |
src/tools seems fine :) I don't have strong opinions on how the tool itself should be designed - either a configuration file or hard-coding the patterns seems fine since it's going to be quick to compile. |
Ok, could you also give some feedback on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, please put it in src/tools
, src/bootstrap is specifically for rustbuild.
@jyn514 I've applied most of your suggestions and I've written some (hacky) code for the |
@rustbot ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I should have been more clear: I'm not particularly keen on moving it into its own tool now. If the tool itself stays quite small and static but suggestions are dynamically loaded then it kind of seems unnecessarily complex but I'll move it into src/tools if you want.
ah interesting! ok, that seems reasonable now that you're using reflection in bootstrap itself :) looks like you haven't started working on the dynamic suggestions yet - I was imaging that as a JSON file, something like this:
$ cat src/bootstrap/suggestions.json
{
"path": "compiler/rustc_data_structures/*",
"suggestions": [
{"cmd": "check"},
{"cmd": "test", "stage": 0, "paths": ["tidy", "compiler/rustc_data_structures"] }
]
}
/// Creates a new standalone builder for use outside of the normal process | ||
pub fn new_standalone( | ||
build: &mut Build, | ||
kind: Kind, | ||
paths: Vec<PathBuf>, | ||
stage: Option<u32>, | ||
) -> Builder<'_> { | ||
// FIXME: don't mutate `build` | ||
if let Some(stage) = stage { | ||
build.config.stage = stage; | ||
} | ||
|
||
Self::new_internal(build, kind, paths.to_owned()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can avoid needing this new function by modifying build.config.cmd
and using Builder::new
instead. You could change sug!
to generate the command for you so it's not too much of a pain:
(test, $stage:literal, $paths:expr) => Suggestion { stage: $stage, cmd: Subcommand::Test { paths: $paths } },
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the idea, I think I also need to modify build.config.stage
. Sorry I'm on holiday right now so the progress is slow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to apologize! You're responding quite fast actually 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, using serde_json
means that we can't directly create Subcommand
s. Honestly, the solution is good enough as is for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the problem, sorry - how is serde_json related here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ezrashaw I don't think I ever got an answer here - how is serde related?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, using serde_json means that we can't directly create Subcommands. Honestly, the solution is good enough as is for now.
Sorry about that. I have no idea what I was thinking lol. I think that this isn't that relevant anymore since suggestions are implemented in code.
Seems quite complex :P. I was thinking more like plain text if that's ok, because then it becomes easier to write tidy checks, etc. Assuming JSON, is there a library preference? |
Bootstrap already uses What would a text format look like? The fields you're parsing are pretty nested, I worry that using a non-structured format would be pretty ambiguous. |
Yes, that's a good point. Also it's probably easier to How should we go about compiling a list of suggestions? Obviously it can be expanded over time but some more now might be good. Maybe also a tidy check for this because if you have bad JSON then it'll only get picked up on at runtime (not tested)? And some kind of check to make sure that files matching the globs do exist, to keep the suggestions in date? |
59e32fd
to
5b78baa
Compare
@jyn514 I've implemented the things we've talked about. I think we should just wait a bit while the reverts happen. It might turn out that this PR brings in the EDIT: I've fixed the merge conflict, basically I cherry-picked the "create EDIT 2: yet another merge conflict 🙄 |
5b78baa
to
655d32d
Compare
☔ The latest upstream changes (presumably #106320) made this pull request unmergeable. Please resolve the merge conflicts. |
655d32d
to
e0a702d
Compare
e0a702d
to
cf29f0d
Compare
☔ The latest upstream changes (presumably #106324) made this pull request unmergeable. Please resolve the merge conflicts. |
Create "suggested tests" tool in `rustbuild` Not the claimed person in rust-lang#97339 but: I've done a very rough implementation of this feature in-tree. I'm very new to `rustc` development (outside of docs) so some help would be greatly appreciated. The UI of this new subcommand obviously will change and I need some mentoring with the `--run` flag. r? ``@jyn514``
This failed in a rollup: https://github.com/rust-lang-ci/rust/actions/runs/4667818566/jobs/8264150865
@bors r- |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
@compiler-errors Could I get a re-roll please? Issue occurred when using a CI-only cargo feature. |
IIIRC, build metrics are enabled in all CI jobs. I'm not happy with the solution you found, but making this work with build metrics can be done as a follow-up. |
Keep in mind that CI should never need to run Unfortunately, upstream changes are required for |
…14,albertlarsan68 Create "suggested tests" tool in `rustbuild` Not the claimed person in rust-lang#97339 but: I've done a very rough implementation of this feature in-tree. I'm very new to `rustc` development (outside of docs) so some help would be greatly appreciated. The UI of this new subcommand obviously will change and I need some mentoring with the `--run` flag. r? `@jyn514`
…14,albertlarsan68 Create "suggested tests" tool in `rustbuild` Not the claimed person in rust-lang#97339 but: I've done a very rough implementation of this feature in-tree. I'm very new to `rustc` development (outside of docs) so some help would be greatly appreciated. The UI of this new subcommand obviously will change and I need some mentoring with the `--run` flag. r? ``@jyn514``
Rollup of 7 pull requests Successful merges: - rust-lang#103682 (Stabilize rustdoc `--test-run-directory`) - rust-lang#106249 (Create "suggested tests" tool in `rustbuild`) - rust-lang#110047 (Add link to `collections` docs to `extend` trait) - rust-lang#110269 (Add `tidy-alphabetical` to features in `core`) - rust-lang#110292 (Add `tidy-alphabetical` to features in `alloc` & `std`) - rust-lang#110305 (rustdoc-search: use ES6 `Map` and `Set` where they make sense) - rust-lang#110315 (Add a stable MIR way to get the main function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…mulacrum Fix the test directories suggested by `./x.py suggest` It seems that these paths were correct when rust-lang#106249 was being written, but since then rust-lang#106458 has been merged (moving `src/test/` to `tests/`), making the tool's suggestions incorrect.
…mulacrum Fix the test directories suggested by `./x.py suggest` It seems that these paths were correct when rust-lang#106249 was being written, but since then rust-lang#106458 has been merged (moving `src/test/` to `tests/`), making the tool's suggestions incorrect.
…mulacrum Fix the test directories suggested by `./x.py suggest` It seems that these paths were correct when rust-lang#106249 was being written, but since then rust-lang#106458 has been merged (moving `src/test/` to `tests/`), making the tool's suggestions incorrect.
Not the claimed person in #97339 but:
I've done a very rough implementation of this feature in-tree. I'm very new to
rustc
development (outside of docs) so some help would be greatly appreciated. The UI of this new subcommand obviously will change and I need some mentoring with the--run
flag.r? @jyn514