mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-28 03:07:24 +03:00
compiletest: Add AuxCrate struct with docs.
To make the code clearer.
This commit is contained in:
@@ -8,8 +8,8 @@
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
@@ -7,6 +7,16 @@
|
||||
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 {
|
||||
@@ -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
|
||||
@@ -34,7 +44,7 @@ pub(crate) fn all_aux_path_strings(&self) -> impl Iterator<Item = &str> {
|
||||
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))
|
||||
}
|
||||
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
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};
|
||||
@@ -1285,9 +1285,9 @@ fn build_all_auxiliary(&self, aux_dir: &Utf8Path, rustc: &mut Command) {
|
||||
}
|
||||
};
|
||||
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user