From 1427c101f98c72e551fcc72671ab3cde0991bb6d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 4 May 2026 10:35:58 +0900 Subject: test(resolver): scaffold PoolBuilder fixture suite from Composer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Port the 31 .test fixtures under composer/tests/Composer/Test/DependencyResolver/Fixtures/poolbuilder/ as #[ignore]'d cases in mozart-registry/tests/poolbuilder.rs. Each fixture is parsed eagerly so format-level regressions surface immediately, while the runner itself is unimplemented\!() — removing #[ignore] from a case will force the missing pool-build entry point into existence rather than silently mis-run. Generalize mozart-test-harness's split_sections to take a per-format valid-section list and add a poolbuilder parser alongside the installer one. --- crates/mozart-test-harness/src/parser.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'crates/mozart-test-harness/src/parser.rs') diff --git a/crates/mozart-test-harness/src/parser.rs b/crates/mozart-test-harness/src/parser.rs index 827272b..ecefb37 100644 --- a/crates/mozart-test-harness/src/parser.rs +++ b/crates/mozart-test-harness/src/parser.rs @@ -45,7 +45,7 @@ pub fn parse_test_file(path: &Path) -> Result { } pub fn parse_test_str(content: &str) -> Result { - let mut sections = split_sections(content)?; + let mut sections = split_sections(content, VALID_SECTIONS)?; for required in REQUIRED_SECTIONS { if !sections.contains_key(*required) { @@ -86,7 +86,15 @@ pub fn parse_test_str(content: &str) -> Result { }) } -fn split_sections(content: &str) -> Result> { +/// Split a `.test` fixture into its `--SECTION--` blocks. +/// +/// Shared helper for both [`parse_test_str`] and the sibling pool-builder +/// parser; each caller passes its own allowed-section list so unknown +/// headers still surface as parse errors rather than silently ignored. +pub(crate) fn split_sections( + content: &str, + valid_sections: &[&str], +) -> Result> { let header_re = regex::Regex::new(r"^--([A-Z][A-Z-]*)--$").unwrap(); let mut sections: IndexMap = IndexMap::new(); @@ -97,7 +105,7 @@ fn split_sections(content: &str) -> Result> { let trimmed = line.trim_end_matches('\n').trim_end_matches('\r'); if let Some(caps) = header_re.captures(trimmed) { let name = caps[1].to_string(); - if !VALID_SECTIONS.contains(&name.as_str()) { + if !valid_sections.contains(&name.as_str()) { bail!("unknown section: --{name}--"); } if let Some(prev) = current_section.take() { -- cgit v1.3.1