Repository navigation
Closed as not planned
Closed as not planned
Copy link
Labels
A-save-analysisArea: saving results of analyses such as inference and borrowck results to a file.Area: saving results of analyses such as inference and borrowck results to a file.A-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Description
#96777 was necessary because a test used both -Zsave-analysis and run-pass. That generated an untracked save-analysis-temp file in the root directory. That behavior is not great - we shouldn't do that even if the test is marked run-pass. We can avoid it by passing --out-dir config.build_base in compiletest:
rust/src/tools/compiletest/src/runtest.rs
Lines 1895 to 1907 in fee75fb
| match output_file { | |
| TargetLocation::ThisFile(path) => { | |
| rustc.arg("-o").arg(path); | |
| } | |
| TargetLocation::ThisDirectory(path) => { | |
| if is_rustdoc { | |
| // `rustdoc` uses `-o` for the output directory. | |
| rustc.arg("-o").arg(path); | |
| } else { | |
| rustc.arg("--out-dir").arg(path); | |
| } | |
| } | |
| } |
We should also investigate why this wasn't caught by CI - it makes the source directory read only, which should have prevented this being merged.
@rustbot label +E-easy +A-testsuite +E-mentor
Metadata
Metadata
Assignees
Labels
A-save-analysisArea: saving results of analyses such as inference and borrowck results to a file.Area: saving results of analyses such as inference and borrowck results to a file.A-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Activity
jyn514 commentedon May 10, 2022
I think it might run x.py from a working directory other than the source root.
kingdido999 commentedon May 12, 2022
@rustbot claim
lionellloh commentedon May 25, 2022
@kingdido999 are you still working on it?
lionellloh commentedon May 30, 2022
@rustbot claim
lionellloh commentedon May 30, 2022
Hey @jyn514, thanks for offering to mentor!
Some questions -
What is the difference between
check-passandrun-pass?What is the best way to repro this?
jyn514 commentedon May 30, 2022
@lionellloh "the difference between cargo check and cargo run" - the first just runs
rustc --emit metadatawhile the second actually generates a binary and runs it. The reason it causes trouble here is because save-analysis uses --out-dir to determine where to put the generated JSON file, and defaults to the working directory if it isn't passed.Change any existing UI test with -Z save-analysis and check-pass to be run-pass instead.
lionellloh commentedon May 30, 2022
@jyn514
Qq regarding dev efficiency:
I managed to repro the issue by running
./x.py test src/test/ui/const-generics/const-argument-non-static-lifetime.rsand changingcheck-passto berun-pass.The command ran for 10 minutes. I deleted the
save-analysis-tempfolder after the repro, made my patch and tried to run again. I realised the tests were ignored this time. I deleted the build folder so that the tests may not be ignored, but it seems like that causes the test to run for a pretty long time again. I wonder if that is avoidable?One more n00b qn:
I am a little curious how
// [full] run-passis parsed. They seem like comments to me. Why does changing it change anything?jyn514 commentedon May 30, 2022
@lionellloh
touch src/test/ui/const-generics/const-argument-non-static-lifetime.rsshould work and be quite fast.jyn514 commentedon May 30, 2022
I think there's also a force-rerun flag or something like that.
14 remaining items
azadnn commentedon Jan 12, 2023
@rustbot claim
azadnn commentedon Jan 12, 2023
Hi @jyn514,
I have spent some time looking at this issue and I can see that, as you indicated above, the (only) likely solution is to set the
RUST_SAVE_ANALYSIS_CONFIGenvironment variable. This is becauserustc_save_analysisis always called withconfig=Noneas can be seen here:rust/compiler/rustc_driver/src/lib.rs
Lines 378 to 386 in 05c1ac0
I see an example of the
RUST_SAVE_ANALYSIS_CONFIGenv variable thoughoutput_fileis null here:rust/src/bootstrap/builder.rs
Lines 1795 to 1801 in 40ba0e8
My observation is that when
run-passtests are run,output_filematchesTargetLocation::ThisFile(path)which is where I propose to set the environment variable:rust/src/tools/compiletest/src/runtest.rs
Lines 1995 to 1998 in 40ba0e8
I should post a PR soon
Rollup merge of rust-lang#106789 - azadnn:save-analysis-for-runpass-t…
Set RUST_SAVE_ANALYSIS_CONFIG env variable for run-pass tests
jyn514 commentedon Feb 19, 2023
Save-analysis has been removed from the compiler.