ensure that compile-flags arguments are the last in ui tests
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.
This commit is contained in:
parent
31d754a1df
commit
6457df3d4b
@ -1499,10 +1499,13 @@ impl<'test> TestCx<'test> {
|
||||
_ => AllowUnused::No,
|
||||
};
|
||||
|
||||
let mut rustc =
|
||||
self.make_compile_args(&self.testpaths.file, output_file, emit_metadata, allow_unused);
|
||||
|
||||
rustc.arg("-L").arg(&self.aux_output_dir_name());
|
||||
let rustc = self.make_compile_args(
|
||||
&self.testpaths.file,
|
||||
output_file,
|
||||
emit_metadata,
|
||||
allow_unused,
|
||||
LinkToAux::Yes,
|
||||
);
|
||||
|
||||
self.compose_and_run_compiler(rustc, None)
|
||||
}
|
||||
@ -1729,8 +1732,13 @@ impl<'test> TestCx<'test> {
|
||||
// Create the directory for the stdout/stderr files.
|
||||
create_dir_all(aux_cx.output_base_dir()).unwrap();
|
||||
let input_file = &aux_testpaths.file;
|
||||
let mut aux_rustc =
|
||||
aux_cx.make_compile_args(input_file, aux_output, EmitMetadata::No, AllowUnused::No);
|
||||
let mut aux_rustc = aux_cx.make_compile_args(
|
||||
input_file,
|
||||
aux_output,
|
||||
EmitMetadata::No,
|
||||
AllowUnused::No,
|
||||
LinkToAux::No,
|
||||
);
|
||||
|
||||
for key in &aux_props.unset_rustc_env {
|
||||
aux_rustc.env_remove(key);
|
||||
@ -1869,6 +1877,7 @@ impl<'test> TestCx<'test> {
|
||||
output_file: TargetLocation,
|
||||
emit_metadata: EmitMetadata,
|
||||
allow_unused: AllowUnused,
|
||||
link_to_aux: LinkToAux,
|
||||
) -> Command {
|
||||
let is_aux = input_file.components().map(|c| c.as_os_str()).any(|c| c == "auxiliary");
|
||||
let is_rustdoc = self.is_rustdoc() && !is_aux;
|
||||
@ -2056,6 +2065,10 @@ impl<'test> TestCx<'test> {
|
||||
rustc.arg("-Ctarget-feature=-crt-static");
|
||||
}
|
||||
|
||||
if let LinkToAux::Yes = link_to_aux {
|
||||
rustc.arg("-L").arg(self.aux_output_dir_name());
|
||||
}
|
||||
|
||||
rustc.args(&self.props.compile_flags);
|
||||
|
||||
rustc
|
||||
@ -2247,13 +2260,16 @@ impl<'test> TestCx<'test> {
|
||||
// codegen tests (using FileCheck)
|
||||
|
||||
fn compile_test_and_save_ir(&self) -> ProcRes {
|
||||
let aux_dir = self.aux_output_dir_name();
|
||||
|
||||
let output_file = TargetLocation::ThisDirectory(self.output_base_dir());
|
||||
let input_file = &self.testpaths.file;
|
||||
let mut rustc =
|
||||
self.make_compile_args(input_file, output_file, EmitMetadata::No, AllowUnused::No);
|
||||
rustc.arg("-L").arg(aux_dir).arg("--emit=llvm-ir");
|
||||
let mut rustc = self.make_compile_args(
|
||||
input_file,
|
||||
output_file,
|
||||
EmitMetadata::No,
|
||||
AllowUnused::No,
|
||||
LinkToAux::Yes,
|
||||
);
|
||||
rustc.arg("--emit=llvm-ir");
|
||||
|
||||
self.compose_and_run_compiler(rustc, None)
|
||||
}
|
||||
@ -2265,10 +2281,13 @@ impl<'test> TestCx<'test> {
|
||||
|
||||
let output_file = TargetLocation::ThisFile(output_path.clone());
|
||||
let input_file = &self.testpaths.file;
|
||||
let mut rustc =
|
||||
self.make_compile_args(input_file, output_file, EmitMetadata::No, AllowUnused::No);
|
||||
|
||||
rustc.arg("-L").arg(self.aux_output_dir_name());
|
||||
let mut rustc = self.make_compile_args(
|
||||
input_file,
|
||||
output_file,
|
||||
EmitMetadata::No,
|
||||
AllowUnused::No,
|
||||
LinkToAux::Yes,
|
||||
);
|
||||
|
||||
match self.props.assembly_output.as_ref().map(AsRef::as_ref) {
|
||||
Some("emit-asm") => {
|
||||
@ -2409,8 +2428,8 @@ impl<'test> TestCx<'test> {
|
||||
output_file,
|
||||
EmitMetadata::No,
|
||||
AllowUnused::Yes,
|
||||
LinkToAux::Yes,
|
||||
);
|
||||
rustc.arg("-L").arg(&new_rustdoc.aux_output_dir_name());
|
||||
new_rustdoc.build_all_auxiliary(&mut rustc);
|
||||
|
||||
let proc_res = new_rustdoc.document(&compare_dir);
|
||||
@ -3354,13 +3373,13 @@ impl<'test> TestCx<'test> {
|
||||
if self.props.run_rustfix && self.config.compare_mode.is_none() {
|
||||
// And finally, compile the fixed code and make sure it both
|
||||
// succeeds and has no diagnostics.
|
||||
let mut rustc = self.make_compile_args(
|
||||
let rustc = self.make_compile_args(
|
||||
&self.testpaths.file.with_extension(UI_FIXED),
|
||||
TargetLocation::ThisFile(self.make_exe_name()),
|
||||
emit_metadata,
|
||||
AllowUnused::No,
|
||||
LinkToAux::Yes,
|
||||
);
|
||||
rustc.arg("-L").arg(&self.aux_output_dir_name());
|
||||
let res = self.compose_and_run_compiler(rustc, None);
|
||||
if !res.status.success() {
|
||||
self.fatal_proc_rec("failed to compile fixed code", &res);
|
||||
@ -3948,3 +3967,8 @@ enum AllowUnused {
|
||||
Yes,
|
||||
No,
|
||||
}
|
||||
|
||||
enum LinkToAux {
|
||||
Yes,
|
||||
No,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user