diff --git a/changelog.d/+residual-spacing.bugfix.md b/changelog.d/+residual-spacing.bugfix.md new file mode 100644 index 00000000..c7a8d052 --- /dev/null +++ b/changelog.d/+residual-spacing.bugfix.md @@ -0,0 +1 @@ +The `package plan` residuals for an inferred moduleclass and for a dropped build requirement, and the source finding for a tree that declares no version, read as one sentence instead of carrying a run of spaces where the source line was wrapped. diff --git a/src/artifact_class.rs b/src/artifact_class.rs index f9ee0e71..45402667 100644 --- a/src/artifact_class.rs +++ b/src/artifact_class.rs @@ -315,7 +315,8 @@ pub fn verify_declared_version( let mut findings = Vec::new(); let Some(declared) = declared else { findings.push(SourceFinding::warning( - "no build system in the source tree declares a version, so the recipe version is unverified against what the code reports" + "no build system in the source tree declares a version, so the recipe version \ + is unverified against what the code reports" .into(), )); return findings; @@ -670,6 +671,11 @@ mod declared_version_tests { let findings = verify_declared_version("1.0.0", None); assert_eq!(findings.len(), 1); assert_eq!(findings[0].level, FindingLevel::Warning); + assert_eq!( + findings[0].message, + "no build system in the source tree declares a version, so the recipe version \ + is unverified against what the code reports" + ); } /// The real case: a snapshot named after the last release tag while the diff --git a/src/package_workflow.rs b/src/package_workflow.rs index 4bf1a222..976748b7 100644 --- a/src/package_workflow.rs +++ b/src/package_workflow.rs @@ -445,7 +445,8 @@ fn drop_unavailable_build_requirements( category: "build-requirement".into(), severity: ResidualSeverity::Judgment, summary: format!( - "{name} is a stated build requirement and this tree carries no module for it, so the recipe does not name it" + "{name} is a stated build requirement and this tree carries no module for it, \ + so the recipe does not name it" ), evidence: None, provenance: None, @@ -581,7 +582,8 @@ fn note_inferred_moduleclass(plan: &mut PackagePlan) { category: "moduleclass".into(), severity: ResidualSeverity::Judgment, summary: format!( - "moduleclass {moduleclass} is inferred from the package's own classifiers; this tree carries no other recipe for {} to take it from", + "moduleclass {moduleclass} is inferred from the package's own classifiers; \ + this tree carries no other recipe for {} to take it from", plan.package.name ), evidence: None, @@ -3103,3 +3105,44 @@ mod portable_path_tests { assert_eq!(portable_easyconfig_path(""), ""); } } + +#[cfg(test)] +mod residual_text_tests { + use super::{ + add_gcccore_binutils, drop_unavailable_build_requirements, inspect_new_package, + note_inferred_moduleclass, ForeignFormat, + }; + use crate::domain::Toolchain; + use std::path::Path; + + #[test] + fn residual_summaries_read_as_one_sentence() { + let source = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("fixtures/foreign_ingest/pypi_bs4/pypi.json"); + let toolchain = Toolchain { + name: "GCCcore".into(), + version: "15.2.0".into(), + }; + let (mut plan, _) = + inspect_new_package(&source, Some(ForeignFormat::Pypi), &toolchain, &[]) + .expect("inspect the PyPI fixture"); + plan.residuals.clear(); + note_inferred_moduleclass(&mut plan); + add_gcccore_binutils(&mut plan); + drop_unavailable_build_requirements(&mut plan, &[]); + let summaries: Vec<&str> = plan + .residuals + .iter() + .map(|residual| residual.summary.as_str()) + .collect(); + assert_eq!( + summaries, + [ + "moduleclass tools is inferred from the package's own classifiers; \ + this tree carries no other recipe for beautifulsoup4 to take it from", + "binutils is a stated build requirement and this tree carries no module \ + for it, so the recipe does not name it", + ] + ); + } +}