Add --test arg to cargo-test-bpf (#14342)
This commit is contained in:
parent
d63dd95806
commit
3d0cd2cdb0
|
@ -16,6 +16,7 @@ struct Config {
|
||||||
cargo_build_bpf: PathBuf,
|
cargo_build_bpf: PathBuf,
|
||||||
extra_cargo_test_args: Vec<String>,
|
extra_cargo_test_args: Vec<String>,
|
||||||
features: Vec<String>,
|
features: Vec<String>,
|
||||||
|
test_name: Option<String>,
|
||||||
no_default_features: bool,
|
no_default_features: bool,
|
||||||
offline: bool,
|
offline: bool,
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
|
@ -31,6 +32,7 @@ impl Default for Config {
|
||||||
cargo_build_bpf: PathBuf::from("cargo-build-bpf"),
|
cargo_build_bpf: PathBuf::from("cargo-build-bpf"),
|
||||||
extra_cargo_test_args: vec![],
|
extra_cargo_test_args: vec![],
|
||||||
features: vec![],
|
features: vec![],
|
||||||
|
test_name: None,
|
||||||
no_default_features: false,
|
no_default_features: false,
|
||||||
offline: false,
|
offline: false,
|
||||||
verbose: false,
|
verbose: false,
|
||||||
|
@ -106,6 +108,11 @@ fn test_bpf_package(
|
||||||
|
|
||||||
cargo_args.insert(0, "test");
|
cargo_args.insert(0, "test");
|
||||||
|
|
||||||
|
if let Some(test_name) = &config.test_name {
|
||||||
|
cargo_args.push("--test");
|
||||||
|
cargo_args.push(test_name);
|
||||||
|
}
|
||||||
|
|
||||||
// If the program crate declares the "test-bpf" feature, pass it along to the tests so they can
|
// If the program crate declares the "test-bpf" feature, pass it along to the tests so they can
|
||||||
// distinguish between `cargo test` and `cargo test-bpf`
|
// distinguish between `cargo test` and `cargo test-bpf`
|
||||||
if set_test_bpf_feature {
|
if set_test_bpf_feature {
|
||||||
|
@ -191,6 +198,13 @@ fn main() {
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
.help("Do not activate the `default` feature"),
|
.help("Do not activate the `default` feature"),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("test")
|
||||||
|
.long("test")
|
||||||
|
.value_name("NAME")
|
||||||
|
.takes_value(true)
|
||||||
|
.help("Test only the specified test target"),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("manifest_path")
|
Arg::with_name("manifest_path")
|
||||||
.long("manifest-path")
|
.long("manifest-path")
|
||||||
|
@ -243,6 +257,7 @@ fn main() {
|
||||||
features: values_t!(matches, "features", String)
|
features: values_t!(matches, "features", String)
|
||||||
.ok()
|
.ok()
|
||||||
.unwrap_or_else(Vec::new),
|
.unwrap_or_else(Vec::new),
|
||||||
|
test_name: value_t!(matches, "test", String).ok(),
|
||||||
no_default_features: matches.is_present("no_default_features"),
|
no_default_features: matches.is_present("no_default_features"),
|
||||||
offline: matches.is_present("offline"),
|
offline: matches.is_present("offline"),
|
||||||
verbose: matches.is_present("verbose"),
|
verbose: matches.is_present("verbose"),
|
||||||
|
|
Loading…
Reference in New Issue