Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use tracing::*;

use crate::common::{CodegenBackend, Config, Debugger, FailMode, PassMode, RunFailMode, TestMode};
use crate::debuggers::{extract_cdb_version, extract_gdb_version};
pub(crate) use crate::directives::auxiliary::AuxProps;
use crate::directives::auxiliary::parse_and_update_aux;
pub(crate) use crate::directives::auxiliary::{AuxCrate, AuxProps};
use crate::directives::directive_names::{
KNOWN_DIRECTIVE_NAMES_SET, KNOWN_HTMLDOCCK_DIRECTIVE_NAMES, KNOWN_JSONDOCCK_DIRECTIVE_NAMES,
};
Expand Down
24 changes: 17 additions & 7 deletions src/tools/compiletest/src/directives/auxiliary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ use super::directives::{AUX_BIN, AUX_BUILD, AUX_CODEGEN_BACKEND, AUX_CRATE, PROC
use crate::common::Config;
use crate::directives::DirectiveLine;

/// The value of an `aux-crate` directive.
#[derive(Clone, Debug, Default)]
pub struct AuxCrate {
/// With `aux-crate: foo=bar.rs` this will be `foo`.
/// With `aux-crate: noprelude:foo=bar.rs` this will be `noprelude:foo`.
pub name: String,
/// With `aux-crate: foo=bar.rs` this will be `bar.rs`.
pub path: String,
}

/// Properties parsed from `aux-*` test directives.
#[derive(Clone, Debug, Default)]
pub(crate) struct AuxProps {
Expand All @@ -17,7 +27,7 @@ pub(crate) struct AuxProps {
pub(crate) bins: Vec<String>,
/// Similar to `builds`, but a list of NAME=somelib.rs of dependencies
/// to build and pass with the `--extern` flag.
pub(crate) crates: Vec<(String, String)>,
pub(crate) crates: Vec<AuxCrate>,
/// Same as `builds`, but for proc-macros.
pub(crate) proc_macros: Vec<String>,
/// Similar to `builds`, but also uses the resulting dylib as a
Expand All @@ -34,7 +44,7 @@ impl AuxProps {
iter::empty()
.chain(builds.iter().map(String::as_str))
.chain(bins.iter().map(String::as_str))
.chain(crates.iter().map(|(_, path)| path.as_str()))
.chain(crates.iter().map(|c| c.path.as_str()))
.chain(proc_macros.iter().map(String::as_str))
.chain(codegen_backend.iter().map(String::as_str))
}
Expand Down Expand Up @@ -63,10 +73,10 @@ pub(super) fn parse_and_update_aux(
}
}

fn parse_aux_crate(r: String) -> (String, String) {
fn parse_aux_crate(r: String) -> AuxCrate {
let mut parts = r.trim().splitn(2, '=');
(
parts.next().expect("missing aux-crate name (e.g. log=log.rs)").to_string(),
parts.next().expect("missing aux-crate value (e.g. log=log.rs)").to_string(),
)
AuxCrate {
name: parts.next().expect("missing aux-crate name (e.g. log=log.rs)").to_string(),
path: parts.next().expect("missing aux-crate value (e.g. log=log.rs)").to_string(),
}
}
8 changes: 4 additions & 4 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::common::{
TestSuite, UI_EXTENSIONS, UI_FIXED, UI_RUN_STDERR, UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG,
UI_WINDOWS_SVG, expected_output_path, incremental_dir, output_base_dir, output_base_name,
};
use crate::directives::TestProps;
use crate::directives::{AuxCrate, TestProps};
use crate::errors::{Error, ErrorKind, load_errors};
use crate::output_capture::ConsoleOut;
use crate::read2::{Truncated, read2_abbreviated};
Expand Down Expand Up @@ -1285,9 +1285,9 @@ impl<'test> TestCx<'test> {
}
};

for (aux_name, aux_path) in &self.props.aux.crates {
let aux_type = self.build_auxiliary(&aux_path, &aux_dir, None);
add_extern(rustc, aux_name, aux_path, aux_type);
for AuxCrate { name, path } in &self.props.aux.crates {
let aux_type = self.build_auxiliary(&path, &aux_dir, None);
add_extern(rustc, name, path, aux_type);
}

for proc_macro in &self.props.aux.proc_macros {
Expand Down
Loading