Skip to content

Commit

Permalink
Add test with custom build script
Browse files Browse the repository at this point in the history
  • Loading branch information
justahero committed Apr 5, 2024
1 parent 96d1d3a commit 74dafa0
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion tests/testsuite/sbom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,49 @@ fn build_sbom_with_simple_build_script() {
assert!(path.is_file());

let json = read_json(path).expect("Failed to read JSON");
dbg!(&json);
// TODO: check SBOM output
}

#[cargo_test]
fn build_sbom_with_build_dependencies() {
let p = configured_project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[dependencies]
bar = { path = "./bar" }
"#,
)
.file("src/main.rs", "fn main() { let _i = bar::bar(); }")
.file("bar/src/lib.rs", "pub fn bar() -> i32 { 2 }")
.file(
"bar/Cargo.toml",
r#"
[package]
name = "bar"
version = "0.1.0"
build = "build.rs"
[build-dependencies]
cc = "1.0.46"
"#,
)
.file(
"bar/build.rs",
r#"fn main() { println!("cargo::rustc-cfg=foo"); }"#,
)
.build();

p.cargo("build -Zsbom")
.stream()
.masquerade_as_nightly_cargo(&["sbom"])
.run();
let path = p.bin("foo").with_extension("cargo-sbom.json");
let json = read_json(path).expect("Failed to read JSON");
// TODO: check SBOM output
}

0 comments on commit 74dafa0

Please sign in to comment.