Skip to content

Commit d887374

Browse files
committed
Add a test to ensure proc macros are reported as build dependencies
1 parent 61fee49 commit d887374

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

  • cargo-auditable/tests

cargo-auditable/tests/it.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,3 +552,36 @@ fn test_path_not_equal_name_inner(sbom: bool) {
552552
.iter()
553553
.any(|p| p.name == "baz" && p.kind == DependencyKind::Runtime));
554554
}
555+
556+
#[test]
557+
fn test_proc_macro() {
558+
//test_proc_macro_inner(false); //TODO
559+
test_proc_macro_inner(true);
560+
}
561+
fn test_proc_macro_inner(sbom: bool) {
562+
// Path to workspace fixture Cargo.toml. See that file for overview of workspace members and their dependencies.
563+
let workspace_cargo_toml = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
564+
.join("tests/fixtures/proc-macro-dependency/Cargo.toml");
565+
// Run in workspace root with default features
566+
let bins = run_cargo_auditable(workspace_cargo_toml, &[], &[], sbom);
567+
eprintln!("Proc macro binary map: {bins:?}");
568+
569+
// proc-macro-dependency should depend on
570+
let binary = &bins.get("proc-macro-dependency").unwrap()[0];
571+
let dep_info = get_dependency_info(binary);
572+
eprintln!("{binary} dependency info: {dep_info:?}");
573+
// locate the serde_derive proc macro package
574+
let serde_derive_info = dep_info
575+
.packages
576+
.iter()
577+
.find(|p| p.name == "serde_derive")
578+
.expect("Could not find 'serde_derive' in the embedded dependency list!");
579+
assert_eq!(serde_derive_info.kind, DependencyKind::Build);
580+
// locate the syn package which is norm a dependency of serde-derive
581+
let syn_info = dep_info
582+
.packages
583+
.iter()
584+
.find(|p| p.name == "syn")
585+
.expect("Could not find 'syn' in the embedded dependency list!");
586+
assert_eq!(syn_info.kind, DependencyKind::Build);
587+
}

0 commit comments

Comments
 (0)