Skip to content

Commit 2a99e17

Browse files
committed
Add test with custom build script
1 parent f1192e2 commit 2a99e17

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

tests/testsuite/sbom.rs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,49 @@ fn build_sbom_with_simple_build_script() {
116116
let path = p.bin("foo").with_extension("cargo-sbom.json");
117117
assert!(path.is_file());
118118

119-
let json = read_json(path).expect("Failed to read JSON");
120-
dbg!(&json);
119+
let _json = read_json(path).expect("Failed to read JSON");
120+
// TODO: check SBOM output
121+
}
122+
123+
#[cargo_test]
124+
fn build_sbom_with_build_dependencies() {
125+
let p = configured_project()
126+
.file(
127+
"Cargo.toml",
128+
r#"
129+
[package]
130+
name = "foo"
131+
version = "0.0.1"
132+
authors = []
133+
134+
[dependencies]
135+
bar = { path = "./bar" }
136+
"#,
137+
)
138+
.file("src/main.rs", "fn main() { let _i = bar::bar(); }")
139+
.file("bar/src/lib.rs", "pub fn bar() -> i32 { 2 }")
140+
.file(
141+
"bar/Cargo.toml",
142+
r#"
143+
[package]
144+
name = "bar"
145+
version = "0.1.0"
146+
build = "build.rs"
147+
148+
[build-dependencies]
149+
cc = "1.0.46"
150+
"#,
151+
)
152+
.file(
153+
"bar/build.rs",
154+
r#"fn main() { println!("cargo::rustc-cfg=foo"); }"#,
155+
)
156+
.build();
157+
158+
p.cargo("build -Zsbom")
159+
.masquerade_as_nightly_cargo(&["sbom"])
160+
.run();
161+
let path = p.bin("foo").with_extension("cargo-sbom.json");
162+
let _json = read_json(path).expect("Failed to read JSON");
163+
// TODO: check SBOM output
121164
}

0 commit comments

Comments
 (0)