-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* check UI cases for sbom output * use locally published package instead of fetching crate from crates.io index
- Loading branch information
Showing
21 changed files
with
237 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
mod help; | ||
mod sbom_single_binary; | ||
mod sbom_with_build_dependencies; |
2 changes: 2 additions & 0 deletions
2
tests/testsuite/cargo_build/sbom_single_binary/in/.cargo/config.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build] | ||
sbom = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use cargo_test_support::compare::assert_ui; | ||
use cargo_test_support::current_dir; | ||
use cargo_test_support::file; | ||
use cargo_test_support::prelude::*; | ||
use cargo_test_support::Project; | ||
|
||
#[cargo_test] | ||
fn case() { | ||
let project: Project = Project::from_template(current_dir!().join("in")); | ||
let project_root = project.root(); | ||
let cwd = &project_root; | ||
|
||
snapbox::cmd::Command::cargo_ui() | ||
.arg("build") | ||
.masquerade_as_nightly_cargo(&["-Zsbom"]) | ||
.args(&["-Z", "sbom"]) | ||
.current_dir(cwd) | ||
.assert() | ||
.success() | ||
.stdout_matches(file!("stdout.log")) | ||
.stderr_matches(file!("stderr.log")); | ||
|
||
assert_ui().subset_matches(current_dir!().join("out"), &project_root); | ||
} |
40 changes: 40 additions & 0 deletions
40
tests/testsuite/cargo_build/sbom_single_binary/out/target/debug/foo.cargo-sbom.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"format_version": 1, | ||
"package_id": "path+[ROOTURL]/case#[email protected]", | ||
"name": "foo", | ||
"version": "0.0.1", | ||
"source": "[ROOT]/case", | ||
"target": { | ||
"kind": [ | ||
"bin" | ||
], | ||
"crate_type": "bin", | ||
"name": "foo", | ||
"edition": "2015" | ||
}, | ||
"profile": { | ||
"name": "dev", | ||
"opt_level": "0", | ||
"lto": "false", | ||
"codegen_backend": null, | ||
"codegen_units": null, | ||
"debuginfo": 2, | ||
"split_debuginfo": "unpacked", | ||
"debug_assertions": true, | ||
"overflow_checks": true, | ||
"rpath": false, | ||
"incremental": false, | ||
"panic": "unwind", | ||
"strip": { | ||
"deferred": "None" | ||
} | ||
}, | ||
"packages": [], | ||
"features": [], | ||
"rustc": { | ||
"version": "[..]", | ||
"wrapper": null, | ||
"commit_hash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", | ||
"host": "[..]" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[..] foo v0.0.1 ([ROOT]/case) | ||
[..] `dev` profile [unoptimized + debuginfo] target(s) in [..] |
Empty file.
2 changes: 2 additions & 0 deletions
2
tests/testsuite/cargo_build/sbom_with_build_dependencies/in/.cargo/config.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[build] | ||
sbom = true |
7 changes: 7 additions & 0 deletions
7
tests/testsuite/cargo_build/sbom_with_build_dependencies/in/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "foo" | ||
version = "0.0.1" | ||
authors = [] | ||
|
||
[dependencies] | ||
bar = { path = "./bar" } |
7 changes: 7 additions & 0 deletions
7
tests/testsuite/cargo_build/sbom_with_build_dependencies/in/bar/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "bar" | ||
version = "0.1.0" | ||
build = "build.rs" | ||
|
||
[build-dependencies] | ||
baz = { path = "../baz" } |
3 changes: 3 additions & 0 deletions
3
tests/testsuite/cargo_build/sbom_with_build_dependencies/in/bar/build.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("cargo::rustc-cfg=foo"); | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/testsuite/cargo_build/sbom_with_build_dependencies/in/bar/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub fn bar() -> i32 { | ||
2 | ||
} |
4 changes: 4 additions & 0 deletions
4
tests/testsuite/cargo_build/sbom_with_build_dependencies/in/baz/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
name = "baz" | ||
version = "0.1.0" | ||
authors = [] |
1 change: 1 addition & 0 deletions
1
tests/testsuite/cargo_build/sbom_with_build_dependencies/in/baz/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub fn hello() {} |
3 changes: 3 additions & 0 deletions
3
tests/testsuite/cargo_build/sbom_with_build_dependencies/in/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
let _i = bar::bar(); | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/testsuite/cargo_build/sbom_with_build_dependencies/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use cargo_test_support::compare::assert_ui; | ||
use cargo_test_support::current_dir; | ||
use cargo_test_support::file; | ||
use cargo_test_support::prelude::*; | ||
use cargo_test_support::Project; | ||
|
||
#[cargo_test] | ||
fn case() { | ||
let project: Project = Project::from_template(current_dir!().join("in")); | ||
let project_root = project.root(); | ||
let cwd = &project_root; | ||
|
||
snapbox::cmd::Command::cargo_ui() | ||
.arg("build") | ||
.masquerade_as_nightly_cargo(&["-Zsbom"]) | ||
.args(&["-Z", "sbom"]) | ||
.current_dir(cwd) | ||
.assert() | ||
.success() | ||
.stdout_matches(file!("stdout.log")) | ||
.stderr_matches(file!("stderr.log")); | ||
|
||
assert_ui().subset_matches(current_dir!().join("out"), &project_root); | ||
} |
98 changes: 98 additions & 0 deletions
98
...s/testsuite/cargo_build/sbom_with_build_dependencies/out/target/debug/foo.cargo-sbom.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
"format_version": 1, | ||
"package_id": "path+[ROOTURL]/case#[email protected]", | ||
"name": "foo", | ||
"version": "0.0.1", | ||
"source": "[ROOT]/case", | ||
"target": { | ||
"kind": [ | ||
"bin" | ||
], | ||
"crate_type": "bin", | ||
"name": "foo", | ||
"edition": "2015" | ||
}, | ||
"profile": { | ||
"name": "dev", | ||
"opt_level": "0", | ||
"lto": "false", | ||
"codegen_backend": null, | ||
"codegen_units": null, | ||
"debuginfo": 2, | ||
"split_debuginfo": "unpacked", | ||
"debug_assertions": true, | ||
"overflow_checks": true, | ||
"rpath": false, | ||
"incremental": false, | ||
"panic": "unwind", | ||
"strip": { | ||
"deferred": "None" | ||
} | ||
}, | ||
"packages": [ | ||
{ | ||
"package_id": "bar 0.1.0 (path+[ROOTURL]/case/bar)", | ||
"package": "bar", | ||
"version": "0.1.0", | ||
"features": [], | ||
"build_type": "normal", | ||
"extern_crate_name": "bar", | ||
"dependencies": [ | ||
{ | ||
"name": "bar", | ||
"package_id": "bar 0.1.0 (path+[ROOTURL]/case/bar)", | ||
"version": "0.1.0", | ||
"features": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"package_id": "bar 0.1.0 (path+[ROOTURL]/case/bar)", | ||
"package": "bar", | ||
"version": "0.1.0", | ||
"features": [], | ||
"build_type": "build", | ||
"extern_crate_name": "build_script_build", | ||
"dependencies": [ | ||
{ | ||
"name": "bar", | ||
"package_id": "bar 0.1.0 (path+[ROOTURL]/case/bar)", | ||
"version": "0.1.0", | ||
"features": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"package_id": "bar 0.1.0 (path+[ROOTURL]/case/bar)", | ||
"package": "bar", | ||
"version": "0.1.0", | ||
"features": [], | ||
"build_type": "normal", | ||
"extern_crate_name": "build_script_build", | ||
"dependencies": [ | ||
{ | ||
"name": "baz", | ||
"package_id": "baz 0.1.0 (path+[ROOTURL]/case/baz)", | ||
"version": "0.1.0", | ||
"features": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"package_id": "baz 0.1.0 (path+[ROOTURL]/case/baz)", | ||
"package": "baz", | ||
"version": "0.1.0", | ||
"features": [], | ||
"build_type": "normal", | ||
"extern_crate_name": "baz", | ||
"dependencies": [] | ||
} | ||
], | ||
"features": [], | ||
"rustc": { | ||
"version": "[..]", | ||
"wrapper": null, | ||
"commit_hash": "9b00956e56009bab2aa15d7bff10916599e3d6d6", | ||
"host": "[..]" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/testsuite/cargo_build/sbom_with_build_dependencies/stderr.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[..] 3 packages to latest compatible versions | ||
[..] baz v0.1.0 ([ROOT]/case/baz) | ||
[..] bar v0.1.0 ([ROOT]/case/bar) | ||
[..] foo v0.0.1 ([ROOT]/case) | ||
[..] `dev` profile [unoptimized + debuginfo] target(s) in [..] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters