Skip to content

Commit

Permalink
Use the same AuxProps parser for EarlyProps
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalathar committed Oct 11, 2024
1 parent 78fd3b5 commit 188f7ce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 28 deletions.
31 changes: 5 additions & 26 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ impl HeadersCache {
/// the test.
#[derive(Default)]
pub struct EarlyProps {
pub aux: Vec<String>,
pub aux_bin: Vec<String>,
pub aux_crate: Vec<(String, String)>,
/// Auxiliary crates that should be built and made available to this test.
/// Included in [`EarlyProps`] so that the indicated files can participate
/// in up-to-date checking. Building happens via [`TestProps::aux`] instead.
pub(crate) aux: AuxProps,
pub revisions: Vec<String>,
}

Expand All @@ -57,21 +58,7 @@ impl EarlyProps {
testfile,
rdr,
&mut |HeaderLine { directive: ln, .. }| {
config.push_name_value_directive(ln, directives::AUX_BUILD, &mut props.aux, |r| {
r.trim().to_string()
});
config.push_name_value_directive(
ln,
directives::AUX_BIN,
&mut props.aux_bin,
|r| r.trim().to_string(),
);
config.push_name_value_directive(
ln,
directives::AUX_CRATE,
&mut props.aux_crate,
Config::parse_aux_crate,
);
parse_and_update_aux(config, ln, &mut props.aux);
config.parse_and_update_revisions(ln, &mut props.revisions);
},
);
Expand Down Expand Up @@ -920,14 +907,6 @@ fn iter_header(
}

impl Config {
fn parse_aux_crate(r: String) -> (String, String) {
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(),
)
}

fn parse_and_update_revisions(&self, line: &str, existing: &mut Vec<String>) {
if let Some(raw) = self.parse_name_value_directive(line, "revisions") {
let mut duplicates: HashSet<_> = existing.iter().cloned().collect();
Expand Down
3 changes: 2 additions & 1 deletion src/tools/compiletest/src/header/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ fn aux_build() {
//@ aux-build: b.rs
"
)
.aux,
.aux
.builds,
vec!["a.rs", "b.rs"],
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,8 @@ fn files_related_to_test(
related.push(testpaths.file.clone());
}

for aux in &props.aux {
for aux in &props.aux.builds {
// FIXME(Zalathar): Perform all `auxiliary` path resolution in one place.
let path = testpaths.file.parent().unwrap().join("auxiliary").join(aux);
related.push(path);
}
Expand Down

0 comments on commit 188f7ce

Please sign in to comment.