Skip to content

[DO NOT LOOK] a bunch of compiletest-related changes #136437

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

Closed

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Feb 2, 2025

Some exploratory changes while trying to figure out why cg_clif's tests were failing.

Not intended for review, this PR needs to be broken up into reviewable PRs with logical commits. Only posted for reference purposes.

-        cmd.arg("--src-base").arg(builder.src.join("tests").join(suite));
-        cmd.arg("--build-base").arg(testdir(builder, compiler.host).join(suite));
+        cmd.arg("--src-root").arg(&builder.src);
+        cmd.arg("--src-test-suite-root").arg(builder.src.join("tests").join(suite));
+        cmd.arg("--build-root").arg(&builder.out);
+        cmd.arg("--build-test-suite-root").arg(testdir(builder, compiler.host).join(suite));
$ find tests -type f -exec sed -i 's/{{src-base}}/{{test-suite-src-base}}/g' {} \;
$ find tests -type f -exec sed -i 's/{{rust-src-base}}/{{sysroot-rust-src-base}}/g' {} \;
$ find tests -type f -exec sed -i 's/{{build-base}}/{{test-suite-build-base}}/g' {} \;

Planned PR series

  1. Cleanup is_rustdoc matching logic and remove a useless rustdoc-json Path::join. [compiletest-related cleanups 1/7] Cleanup is_rustdoc logic and remove a useless path join in rustdoc-json runtest logic #136441
  2. Pass --stage as a compiletest flag to not have to do stage-id gymnastics in run-make runtest logic. [compiletest-related cleanups 2/7] Feed stage number to compiletest directly #136472
  3. Rectify src_base handling: split --src-base into two flags, --src-root and --src-test-suite-root, and tidy up logic that exercises src_base previously. Remove find_rust_src_root. [compiletest-related cleanups 3/7] Make the distinction between sources root vs test suite sources root in compiletest less confusing #136474
  4. Rectify build_base handling: split --build-base into two flags, --build-root and --build-test-suite-root, and tidy up logic that exercises build_base previously. [compiletest-related cleanups 4/7] Make the distinction between root build directory vs test suite specific build directory in compiletest less confusing #136542
  5. Rename {{src-base}} -> {{test-suite-src-base}}. Rebless tests. Update rustc-dev-guide.
  6. Rename {{rust-src-base}} -> {{sysroot-rust-src-base}}. Rebless tests. Update rustc-dev-guide.
  7. Rename {{build-base}} -> {{test-suite-build-base}}. Rebless tests. Update rustc-dev-guide.

@rustbot

This comment was marked as off-topic.

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc PG-exploit-mitigations Project group: Exploit mitigations 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) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Feb 2, 2025
@jieyouxu jieyouxu added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. rla-silenced Silences rust-log-analyzer postings to the PR it's added on. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2025
@jieyouxu
Copy link
Member Author

jieyouxu commented Feb 2, 2025

Sorry, forgor to write ghost.

Comment on lines -19 to +24
let root = self.config.find_rust_src_root().unwrap();
let mut json_out = out_dir.join(self.testpaths.file.file_stem().unwrap());
json_out.set_extension("json");
let res = self.run_command_to_procres(
Command::new(self.config.jsondocck_path.as_ref().unwrap())
.arg("--doc-dir")
.arg(root.join(&out_dir))
.arg(&out_dir)
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 simply wrong, and only happens to work because PathBuf::join when the arg is an absolute path out_dir will simply became a replacement operation.

// [local-self] no-remap-src-base: The hack should work regardless of remapping.
// The hack should work regardless of remapping.
Copy link
Member Author

@jieyouxu jieyouxu Feb 2, 2025

Choose a reason for hiding this comment

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

This is kinda-wrong, in the sense that no-remap-src-base is not a directive yet this line looks like a revisioned directive, but also, because this isn't recognized as a revisioned compiletest directive (not //@), it ends up functioning as intended.

Comment on lines -260 to -264
let rust_src_root =
self.config.find_rust_src_root().expect("Could not find Rust source root");
let rust_pp_module_rel_path = Path::new("./src/etc");
let rust_pp_module_abs_path =
rust_src_root.join(rust_pp_module_rel_path).to_str().unwrap().to_owned();
Copy link
Member Author

Choose a reason for hiding this comment

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

Beautiful incantation :ferrisClueless:

Comment on lines -262 to -264
// FIXME(jieyouxu): improve the communication between bootstrap and compiletest here so
// we don't have to hack out a `stageN`.
let stage = self.config.stage_id.split('-').next().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.

Yeah, for example, by actually passing the stage number through a flag like --stage

Comment on lines +386 to +387
// Path to `$build_dir/$host_triple/`.
.env("BUILD_ROOT", &host_build_root)
Copy link
Member Author

Choose a reason for hiding this comment

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

Cheeky, not build/, but build/$host/.

Comment on lines -433 to +406
cmd.env("CARGO", source_root.join(cargo));
cmd.env("CARGO", cargo);
}

if let Some(ref rustdoc) = self.config.rustdoc_path {
cmd.env("RUSTDOC", source_root.join(rustdoc));
cmd.env("RUSTDOC", rustdoc);
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.

self.config.src_base.ends_with("rustdoc-ui")
|| self.config.src_base.ends_with("rustdoc-js")
|| self.config.src_base.ends_with("rustdoc-json")
matches!(self.config.suite.as_str(), "rustdoc-ui" | "rustdoc-js" | "rustdoc-json")
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what's happening here lol

Comment on lines -1037 to -1048
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

Choose a reason for hiding this comment

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

No need to use a heuristic to find source root, when we can just provide it through bootstrap.

Comment on lines -218 to +227
/// The directory containing the tests to run
pub src_base: PathBuf,

/// The directory where programs should be built
pub build_base: PathBuf,

/// The directory containing the compiler sysroot
pub sysroot_base: PathBuf,

/// Path to directory containing rust-lang/rust sources.
pub src_root: PathBuf,
/// Path to the directory containg the test suite sources. Expected to be a subdirectory of
/// `src_root`.
pub src_test_suite_root: PathBuf,

/// Bootstrap build directory.
pub build_root: PathBuf,
/// Bootstrap test suite build directory. Expected to be a subdirectory of `build_root`.
pub build_test_suite_root: PathBuf,
Copy link
Member Author

Choose a reason for hiding this comment

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

These are terribly named, and looking at the runtest impls, it has confused multiple people. src_base is not sources root, it's the directory $SRC_ROOT/tests/<test-suite>/. build_base is not build directory root, it's $BUILD/<host-triple>/test/<test-suite>.

// eg. /home/user/rust/build/x86_64-unknown-linux-gnu/test/ui
normalize_path(test_build_dir, "$TEST_BUILD_DIR");
normalize_path(&self.config.build_test_suite_root, "$TEST_BUILD_DIR");
eprintln!("build_test_suite_root = {:?}", self.config.build_test_suite_root.display());
Copy link
Member Author

Choose a reason for hiding this comment

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

Reminder: delete this

jieyouxu added a commit to jieyouxu/rust that referenced this pull request Feb 3, 2025
…piler-errors

[`compiletest`-related cleanups 1/7] Cleanup `is_rustdoc` logic and remove a useless path join in rustdoc-json runtest logic

Reference for overall changes: rust-lang#136437
Part **1** of **7** of the *`compiletest`-related cleanups* PR series.

### Summary

- Don't match on path when we already have test suite names.
- Remove a useless path join.

r? bootstrap (or compiler)
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 3, 2025
Rollup merge of rust-lang#136441 - jieyouxu:cleanup-is-rustdoc, r=compiler-errors

[`compiletest`-related cleanups 1/7] Cleanup `is_rustdoc` logic and remove a useless path join in rustdoc-json runtest logic

Reference for overall changes: rust-lang#136437
Part **1** of **7** of the *`compiletest`-related cleanups* PR series.

### Summary

- Don't match on path when we already have test suite names.
- Remove a useless path join.

r? bootstrap (or compiler)
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Feb 4, 2025
[`compiletest`-related cleanups 1/7] Cleanup `is_rustdoc` logic and remove a useless path join in rustdoc-json runtest logic

Reference for overall changes: rust-lang/rust#136437
Part **1** of **7** of the *`compiletest`-related cleanups* PR series.

### Summary

- Don't match on path when we already have test suite names.
- Remove a useless path join.

r? bootstrap (or compiler)
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Feb 10, 2025
…crum

[`compiletest`-related cleanups 2/7] Feed stage number to compiletest directly

Reference for overall changes: rust-lang#136437
Part **2** of **7** of the *`compiletest`-related cleanups* PR series.

### Summary

- Pass stage number via new `--stage` compiletest flag directly from bootstrap, instead of deriving that info in compiletest by doing gymnastics on `--stage-id`.
- Just a cleanup, should have no functional changes.

r? bootstrap
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 10, 2025
Rollup merge of rust-lang#136472 - jieyouxu:pass-stage, r=Mark-Simulacrum

[`compiletest`-related cleanups 2/7] Feed stage number to compiletest directly

Reference for overall changes: rust-lang#136437
Part **2** of **7** of the *`compiletest`-related cleanups* PR series.

### Summary

- Pass stage number via new `--stage` compiletest flag directly from bootstrap, instead of deriving that info in compiletest by doing gymnastics on `--stage-id`.
- Just a cleanup, should have no functional changes.

r? bootstrap
@bors
Copy link
Collaborator

bors commented Feb 10, 2025

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

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 10, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 21, 2025
[`compiletest`-related cleanups 3/7] Make the distinction between sources root vs test suite sources root in compiletest less confusing

Reference for overall changes: rust-lang#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
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 21, 2025
[`compiletest`-related cleanups 3/7] Make the distinction between sources root vs test suite sources root in compiletest less confusing

Reference for overall changes: rust-lang#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
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 22, 2025
[`compiletest`-related cleanups 3/7] Make the distinction between sources root vs test suite sources root in compiletest less confusing

Reference for overall changes: rust-lang#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
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 22, 2025
Rollup merge of rust-lang#136474 - jieyouxu:src-base, r=clubby789

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

Reference for overall changes: rust-lang#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
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 27, 2025
[`compiletest`-related cleanups 4/7] Make the distinction between root build directory vs test suite specific build directory in compiletest less confusing

Reference for overall changes: rust-lang#136437
Part **4** of **7** of the *`compiletest`-related cleanups* PR series.

### Summary

- Remove `--build-base` compiletest flag, and introduce `--build-{root,test-suite-root}` flags instead. `--build-base` previously actually is test suite specific build directory, not the root `build/` directory.
- Feed the root build directory directly from bootstrap to compiletest via `--build-root` instead of doing multiple layers of parent unwrapping[^parent] based on the test suite specific build directory.
- Remove a redundant `to_path_buf()`.

[^parent]: Please do not unwrap the parents.

r? bootstrap
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 27, 2025
[`compiletest`-related cleanups 4/7] Make the distinction between root build directory vs test suite specific build directory in compiletest less confusing

Reference for overall changes: rust-lang#136437
Part **4** of **7** of the *`compiletest`-related cleanups* PR series.

### Summary

- Remove `--build-base` compiletest flag, and introduce `--build-{root,test-suite-root}` flags instead. `--build-base` previously actually is test suite specific build directory, not the root `build/` directory.
- Feed the root build directory directly from bootstrap to compiletest via `--build-root` instead of doing multiple layers of parent unwrapping[^parent] based on the test suite specific build directory.
- Remove a redundant `to_path_buf()`.

[^parent]: Please do not unwrap the parents.

r? bootstrap
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 27, 2025
[`compiletest`-related cleanups 4/7] Make the distinction between root build directory vs test suite specific build directory in compiletest less confusing

Reference for overall changes: rust-lang#136437
Part **4** of **7** of the *`compiletest`-related cleanups* PR series.

### Summary

- Remove `--build-base` compiletest flag, and introduce `--build-{root,test-suite-root}` flags instead. `--build-base` previously actually is test suite specific build directory, not the root `build/` directory.
- Feed the root build directory directly from bootstrap to compiletest via `--build-root` instead of doing multiple layers of parent unwrapping[^parent] based on the test suite specific build directory.
- Remove a redundant `to_path_buf()`.

[^parent]: Please do not unwrap the parents.

r? bootstrap
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 28, 2025
Rollup merge of rust-lang#136542 - jieyouxu:build-base, r=onur-ozkan

[`compiletest`-related cleanups 4/7] Make the distinction between root build directory vs test suite specific build directory in compiletest less confusing

Reference for overall changes: rust-lang#136437
Part **4** of **7** of the *`compiletest`-related cleanups* PR series.

### Summary

- Remove `--build-base` compiletest flag, and introduce `--build-{root,test-suite-root}` flags instead. `--build-base` previously actually is test suite specific build directory, not the root `build/` directory.
- Feed the root build directory directly from bootstrap to compiletest via `--build-root` instead of doing multiple layers of parent unwrapping[^parent] based on the test suite specific build directory.
- Remove a redundant `to_path_buf()`.

[^parent]: Please do not unwrap the parents.

r? bootstrap
@jieyouxu
Copy link
Member Author

Closing because I'm not sure if the substitution renaming is worth the churn.

@jieyouxu jieyouxu closed this Mar 20, 2025
@jieyouxu jieyouxu deleted the compiletest-rust-src-root branch March 20, 2025 08:14
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 PG-exploit-mitigations Project group: Exploit mitigations rla-silenced Silences rust-log-analyzer postings to the PR it's added on. S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. 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) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants