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 6, 2024
1 parent 96d1d3a commit 190682e
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions tests/testsuite/sbom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,50 @@ fn build_sbom_with_simple_build_script() {
let path = p.bin("foo").with_extension("cargo-sbom.json");
assert!(path.is_file());

let json = read_json(path).expect("Failed to read JSON");
dbg!(&json);
let _json = read_json(path).expect("Failed to read 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 190682e

Please sign in to comment.