Skip to content

Commit

Permalink
tools/compiletest: fix argument ordering for allowing unused in ui & …
Browse files Browse the repository at this point in the history
…compile-fail tests
  • Loading branch information
tobithiel committed Jan 5, 2020
1 parent 51021b1 commit 3441779
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions src/tools/compiletest/src/runtest.rs
Expand Up @@ -1478,11 +1478,7 @@ impl<'test> TestCx<'test> {
WillExecute::No => TargetLocation::ThisDirectory(self.output_base_dir()),
};

let mut rustc = self.make_compile_args(&self.testpaths.file, output_file, emit_metadata);

rustc.arg("-L").arg(&self.aux_output_dir_name());

match self.config.mode {
let allow_unused = match self.config.mode {
CompileFail | Ui => {
// compile-fail and ui tests tend to have tons of unused code as
// it's just testing various pieces of the compile, but we don't
Expand All @@ -1495,11 +1491,18 @@ impl<'test> TestCx<'test> {
// via command line flags.
&& local_pm != Some(PassMode::Run)
{
rustc.args(&["-A", "unused"]);
AllowUnused::Yes
} else {
AllowUnused::No
}
}
_ => {}
}
_ => 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());

self.compose_and_run_compiler(rustc, None)
}
Expand Down Expand Up @@ -1710,7 +1713,8 @@ 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);
let mut aux_rustc =
aux_cx.make_compile_args(input_file, aux_output, EmitMetadata::No, AllowUnused::No);

let (dylib, crate_type) = if aux_props.no_prefer_dynamic {
(true, None)
Expand Down Expand Up @@ -1819,6 +1823,7 @@ impl<'test> TestCx<'test> {
input_file: &Path,
output_file: TargetLocation,
emit_metadata: EmitMetadata,
allow_unused: AllowUnused,
) -> Command {
let is_rustdoc = self.is_rustdoc();
let mut rustc = if !is_rustdoc {
Expand Down Expand Up @@ -1951,6 +1956,13 @@ impl<'test> TestCx<'test> {
rustc.arg("-Ctarget-feature=-crt-static");
}

match allow_unused {
AllowUnused::Yes => {
rustc.args(&["-A", "unused"]);
}
AllowUnused::No => {}
}

rustc.args(&self.props.compile_flags);

rustc
Expand Down Expand Up @@ -2134,7 +2146,8 @@ impl<'test> TestCx<'test> {

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);
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");

self.compose_and_run_compiler(rustc, None)
Expand All @@ -2147,7 +2160,8 @@ 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);
let mut rustc =
self.make_compile_args(input_file, output_file, EmitMetadata::No, AllowUnused::No);

rustc.arg("-L").arg(self.aux_output_dir_name());

Expand Down Expand Up @@ -2999,6 +3013,7 @@ impl<'test> TestCx<'test> {
&self.testpaths.file.with_extension(UI_FIXED),
TargetLocation::ThisFile(self.make_exe_name()),
emit_metadata,
AllowUnused::No,
);
rustc.arg("-L").arg(&self.aux_output_dir_name());
let res = self.compose_and_run_compiler(rustc, None);
Expand Down Expand Up @@ -3486,6 +3501,11 @@ enum ExpectedLine<T: AsRef<str>> {
Text(T),
}

enum AllowUnused {
Yes,
No,
}

impl<T> fmt::Debug for ExpectedLine<T>
where
T: AsRef<str> + fmt::Debug,
Expand Down

0 comments on commit 3441779

Please sign in to comment.