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

[compiletest-related cleanups 3/7] Make the distinction between sources root vs test suite sources root in compiletest less confusing #136474

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

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Feb 3, 2025

Reference for overall changes: #136437
Part 3 of 7 of the compiletest-related cleanups PR series.

Summary

  • Remove --src-base compiletest in favor of new flags --src-root and --src-test-suite-root which more accurately conveys the intent. --src-base previously actually meant --src-test-suite-root and has caused multiple confusions.
  • Use --src-root to have bootstrap directly feed source root path to compiletest, instead of doing a hacky directory parent search heuristic (find_rust_src_root) that somehow returns an Option<PathBuf>.

Review advice

Best reviewed commit-by-commit.

r? bootstrap

@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 Feb 3, 2025
@jieyouxu jieyouxu changed the title [compiletest-related cleanups3/7] Make the distinction between sources root vs test suite sources root in compiletest less confusing [compiletest-related cleanups 3/7] Make the distinction between sources root vs test suite sources root in compiletest less confusing Feb 3, 2025
@jieyouxu jieyouxu removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 3, 2025
@jieyouxu
Copy link
Member Author

jieyouxu commented Feb 3, 2025

@rustbot blocked (on #136472 and #136441)

@rustbot rustbot added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Feb 3, 2025
Comment on lines -1037 to -1041
pub fn find_rust_src_root(&self) -> Option<PathBuf> {
let mut path = self.src_base.clone();
let path_postfix = Path::new("src/etc/lldb_batchmode.py");

while path.pop() {
if path.join(&path_postfix).is_file() {
return Some(path);
}
}

None
}

Copy link
Member Author

@jieyouxu jieyouxu Feb 3, 2025

Choose a reason for hiding this comment

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

This was semi-necessary back in #16322 (Aug 2014, 11 years ago) because bootstrap didn't exist and compiletest was invoked directly, but now we have bootstrap so this isn't needed anymore.

@bors
Copy link
Contributor

bors commented Feb 10, 2025

☔ The latest upstream changes (presumably #136809) made this pull request unmergeable. Please resolve the merge conflicts.

@jieyouxu
Copy link
Member Author

Prerequisite PRs have merged so this is now unblocked.
@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Feb 10, 2025
Instead of only having `--src-base` and `src_base` which *actually*
refers to the directory containing the test suite and not the sources
root. More importantly, kill off `find_rust_src_root` when we can simply
pass that info from bootstrap.
Comment on lines -936 to +955
//
// FIXME(jieyouxu): untangle these paths, we should provide both a path to root `tests/` or
// `tests/auxiliary/` and the test suite in question. `src_base` is also a terrible name.
related.push(config.src_base.parent().unwrap().join("auxiliary").join("minicore.rs"));
related.push(config.src_root.join("tests").join("auxiliary").join("minicore.rs"));
Copy link
Member Author

Choose a reason for hiding this comment

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

Also helps to cleanup this

Comment on lines -1029 to +1046
// Print the name of the file, relative to the repository root.
// `src_base` looks like `/path/to/rust/tests/ui`
let root_directory = config.src_base.parent().unwrap().parent().unwrap();
let path = testpaths.file.strip_prefix(root_directory).unwrap();
// Print the name of the file, relative to the sources root.
let path = testpaths.file.strip_prefix(&config.src_root).unwrap();
Copy link
Member Author

Choose a reason for hiding this comment

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

And this

self.config.find_rust_src_root().unwrap().join("vendor").display(),
self.config.src_root.join("vendor").to_str().unwrap(),
Copy link
Member Author

Choose a reason for hiding this comment

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

And these

Comment on lines 1634 to +1635
"--remap-path-prefix={}={}",
self.config.src_base.display(),
self.config.src_test_suite_root.to_str().unwrap(),
Copy link
Member Author

Choose a reason for hiding this comment

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

This was very confusing to me, because this is not the source root, but actually the root of the test suite sources

Comment on lines -411 to +390
cmd.env("CARGO", source_root.join(cargo));
cmd.env("CARGO", cargo);
Copy link
Member Author

Choose a reason for hiding this comment

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

Redundant, bootstrap already passes abs path to cargo/rustdoc

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-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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants