Skip to content
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

build_helper::compiletest module factored out of compiletest for use by bootstrap #135653

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lolbinarycat
Copy link
Contributor

closes #135645

@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2025

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 17, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2025

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rust-log-analyzer

This comment has been minimized.

@lolbinarycat lolbinarycat force-pushed the build_helper-compiletest branch from 2272421 to 70eac07 Compare January 17, 2025 20:42
@onur-ozkan
Copy link
Member

r? onur-ozkan

@rustbot rustbot assigned onur-ozkan and unassigned wesleywiser Jan 17, 2025
}

impl Mode {
pub fn aux_dir_disambiguator(self) -> &'static str {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel like these two helpers belong in build_helpers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would require turning them into free functions. do you want me to do that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please do move them as free functions into compiletest, this is an impl detail that doesn't feel like they belong here


string_enum! {
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
pub enum Mode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please call this TestMode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why? the command line flag is called --mode, no? so why shouldn't the struct match?

Copy link
Member

@jieyouxu jieyouxu Jan 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because build_helpers is a shared dep between bootstrap, compiletest, and some other bootstrap tools. bootstrap itself already has a Mode, not to mention Mode is a very generic term.

--mode for compiletest is fine because it's very clear from context as its a flag of the compiletest binary itself (only matters when bootstrap is actually trying to run compiletest binary).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would think its position in the compiletest module would be adequate context.

i can if you really want me to, it's just gonna take a bit since it's refactoring across several crates.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I would prefer if this is called TestMode and not just Mode.

@jieyouxu
Copy link
Member

jieyouxu commented Jan 17, 2025

The one thing that feels slightly iffy to me is that now the compiletest test mode definitions are no longer in compiletest, which makes it more indirect if you want to wire up or remove a test mode, or adjust existing test modes.

But I suppose that's fine.

@jieyouxu jieyouxu self-assigned this Jan 18, 2025
@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 18, 2025
@onur-ozkan
Copy link
Member

The one thing that feels slightly iffy to me is that now the compiletest test mode definitions are no longer in compiletest, which makes it more indirect if you want to wire up or remove a test mode, or adjust existing test modes.

Fair concern as directives are compiletest-first dependency.

How about placing directives module (without any helper functions or additional components) into compiletest and using it in bootstrap with manually specified path mod?

@jieyouxu
Copy link
Member

jieyouxu commented Jan 18, 2025

The one thing that feels slightly iffy to me is that now the compiletest test mode definitions are no longer in compiletest, which makes it more indirect if you want to wire up or remove a test mode, or adjust existing test modes.

Fair concern as directives are compiletest-first dependency.

How about placing directives module (without any helper functions or additional components) into compiletest and using it in bootstrap with manually specified path mod?

Not just directives, but also the concept of test modes and test suites. They are centric to what compiletest is responsible for handling.

I think keeping a very lean TestMode + TestSuite enum definition (no additional helpers modulo the string enum stuff) module in compiletest, then depending on that via path mod in bootstrap is probably more logical, yes. (We can just leave a doc comment on this specific definition module that one must not depend on other parts of compiletest, as bootstrap is designed to consume the enum definitions via #[path] module.)

@lolbinarycat
Copy link
Contributor Author

I've always seen #[path] trickery as a bit of a hack outside of rust's normal dependency model, so i'd like to leave this open for bit to get feedback from other t-bootstrap members before i commit to any specific implementation, if that's alright.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

new build_helper::compiletest module for safer invocations of compiletest by bootstrap
6 participants