Skip to content

Commit 190682e

Browse files
committed
Add test with custom build script
1 parent 96d1d3a commit 190682e

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

tests/testsuite/sbom.rs

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,50 @@ fn build_sbom_with_simple_build_script() {
118118
let path = p.bin("foo").with_extension("cargo-sbom.json");
119119
assert!(path.is_file());
120120

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

0 commit comments

Comments
 (0)