-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Ensure that compile-flags arguments are the last in UI tests #103298
Conversation
r? @jyn514 (rust-highfive has picked a reviewer for you, use r? to override) |
@@ -1869,6 +1877,7 @@ impl<'test> TestCx<'test> { | |||
output_file: TargetLocation, | |||
emit_metadata: EmitMetadata, | |||
allow_unused: AllowUnused, | |||
link_to_aux: LinkToAux, |
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.
for my sanity: this new argument is necessary because there's no Command
available until after this function returns it. We might want to refactor at some point to allow passing custom flags without needing all of them to be passed into this function.
src/tools/compiletest/src/runtest.rs
Outdated
AllowUnused::No, | ||
LinkToAux::Yes, | ||
); | ||
rustc.arg("--emit=llvm-ir"); |
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.
this will have the same problem as -L aux_dir
, right? should we fix that here too?
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, there are multiple places around that add flags. If we wanted to remove all the chances of this happening in the future, we should probably have a
prepare_and_run_rustc(..., |cmd| { cmd.arg("--emit=llvm-ir") });
Would that be something you'd like?
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, that sounds like a lot of changes to use the new API - can we add a src/test/ui
test that verifies this works instead?
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.
Done!
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 adding the test! Looks like this is still broken for codegen tests though, can you add a test for that case too?
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.
Fixed codegen
and asm
test suites. I couldn't add a test though, because both suites expect the compilation to pass, and // build-fail
doesn't work in non-UI suites.
8015e81
to
f869abb
Compare
Before this commit, compiletest would add `-L path/to/aux` at the end of the rustc flags, even after the custom ones set with the compile-flags header comment. This made it impossible to check how rustc would behave when a flag requiring an argument was passed without the argument, because the argument would become `-L`. This PR fixes that by adding the `-L path/to/aux` before the arguments defined in compile-flags, at least for UI tests. Other test suites might either be fixed as well by this change, or still present the old behavior.
f869abb
to
9546490
Compare
src/tools/compiletest/src/runtest.rs
Outdated
AllowUnused::No, | ||
LinkToAux::Yes, | ||
); | ||
rustc.arg("--emit=llvm-ir"); |
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 adding the test! Looks like this is still broken for codegen tests though, can you add a test for that case too?
@rustbot review |
Looks great, thanks! @bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (81ff7e7): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
…yn514 Ensure that compile-flags arguments are the last in UI tests Before this PR, compiletest would add `-L path/to/aux` at the end of the rustc flags, even after the custom ones set with the compile-flags header comment. This made it impossible to check how rustc would behave when a flag requiring an argument was passed without the argument, because the argument would become `-L`. This PR fixes that by adding the `-L path/to/aux` before the arguments defined in compile-flags, at least for UI tests. Other test suites might either be fixed as well by this change, or still present the old behavior (`-L` is now always passed before, but other tests suites might add additional flags after the custom ones).
compiletest: Simplify the choice of `--emit` mode for assembly tests Tiny little cleanup that I noticed while working on rust-lang#131524. No functional change. Historically, the original code structure (rust-lang#58791) predates the `Emit` enum (rust-lang#103298), so it was manually adding `--emit` flags to the compiler invocation. But now the match can just evaluate to the appropriate `Emit` value directly.
Rollup merge of rust-lang#131525 - Zalathar:emit-asm, r=jieyouxu compiletest: Simplify the choice of `--emit` mode for assembly tests Tiny little cleanup that I noticed while working on rust-lang#131524. No functional change. Historically, the original code structure (rust-lang#58791) predates the `Emit` enum (rust-lang#103298), so it was manually adding `--emit` flags to the compiler invocation. But now the match can just evaluate to the appropriate `Emit` value directly.
Before this PR, compiletest would add
-L path/to/aux
at the end of the rustc flags, even after the custom ones set with the compile-flags header comment. This made it impossible to check how rustc would behave when a flag requiring an argument was passed without the argument, because the argument would become-L
.This PR fixes that by adding the
-L path/to/aux
before the arguments defined in compile-flags, at least for UI tests. Other test suites might either be fixed as well by this change, or still present the old behavior (-L
is now always passed before, but other tests suites might add additional flags after the custom ones).