update clap to v3: test-bpf
This commit is contained in:
parent
8abaa5d350
commit
e2bc326d58
|
@ -10,7 +10,7 @@ edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33.3"
|
clap = { version = "3.1.5", features = ["cargo"] }
|
||||||
cargo_metadata = "0.14.2"
|
cargo_metadata = "0.14.2"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use {
|
use {
|
||||||
clap::{
|
clap::{crate_description, crate_name, crate_version, Arg},
|
||||||
crate_description, crate_name, crate_version, value_t, values_t, App, AppSettings, Arg,
|
|
||||||
},
|
|
||||||
std::{
|
std::{
|
||||||
env,
|
env,
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
|
@ -217,104 +215,105 @@ fn main() {
|
||||||
let em_dash = "--".to_string();
|
let em_dash = "--".to_string();
|
||||||
let args_contain_dashash = args.contains(&em_dash);
|
let args_contain_dashash = args.contains(&em_dash);
|
||||||
|
|
||||||
let matches = App::new(crate_name!())
|
let matches = clap::Command::new(crate_name!())
|
||||||
.about(crate_description!())
|
.about(crate_description!())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.setting(AppSettings::TrailingVarArg)
|
.trailing_var_arg(true)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("bpf_sdk")
|
Arg::new("bpf_sdk")
|
||||||
.long("bpf-sdk")
|
.long("bpf-sdk")
|
||||||
.value_name("PATH")
|
.value_name("PATH")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Path to the Solana BPF SDK"),
|
.help("Path to the Solana BPF SDK"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("features")
|
Arg::new("features")
|
||||||
.long("features")
|
.long("features")
|
||||||
.value_name("FEATURES")
|
.value_name("FEATURES")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.multiple(true)
|
.multiple_occurrences(true)
|
||||||
|
.multiple_values(true)
|
||||||
.help("Space-separated list of features to activate"),
|
.help("Space-separated list of features to activate"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("no_default_features")
|
Arg::new("no_default_features")
|
||||||
.long("no-default-features")
|
.long("no-default-features")
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
.help("Do not activate the `default` feature"),
|
.help("Do not activate the `default` feature"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("test")
|
Arg::new("test")
|
||||||
.long("test")
|
.long("test")
|
||||||
.value_name("NAME")
|
.value_name("NAME")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Test only the specified test target"),
|
.help("Test only the specified test target"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("manifest_path")
|
Arg::new("manifest_path")
|
||||||
.long("manifest-path")
|
.long("manifest-path")
|
||||||
.value_name("PATH")
|
.value_name("PATH")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Path to Cargo.toml"),
|
.help("Path to Cargo.toml"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("bpf_out_dir")
|
Arg::new("bpf_out_dir")
|
||||||
.long("bpf-out-dir")
|
.long("bpf-out-dir")
|
||||||
.value_name("DIRECTORY")
|
.value_name("DIRECTORY")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Place final BPF build artifacts in this directory"),
|
.help("Place final BPF build artifacts in this directory"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("no_run")
|
Arg::new("no_run")
|
||||||
.long("no-run")
|
.long("no-run")
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
.help("Compile, but don't run tests"),
|
.help("Compile, but don't run tests"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("offline")
|
Arg::new("offline")
|
||||||
.long("offline")
|
.long("offline")
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
.help("Run without accessing the network"),
|
.help("Run without accessing the network"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("generate_child_script_on_failure")
|
Arg::new("generate_child_script_on_failure")
|
||||||
.long("generate-child-script-on-failure")
|
.long("generate-child-script-on-failure")
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
.help("Generate a shell script to rerun a failed subcommand"),
|
.help("Generate a shell script to rerun a failed subcommand"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("verbose")
|
Arg::new("verbose")
|
||||||
.short("v")
|
.short('v')
|
||||||
.long("verbose")
|
.long("verbose")
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
.help("Use verbose output"),
|
.help("Use verbose output"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("workspace")
|
Arg::new("workspace")
|
||||||
.long("workspace")
|
.long("workspace")
|
||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
.alias("all")
|
.alias("all")
|
||||||
.help("Test all BPF packages in the workspace"),
|
.help("Test all BPF packages in the workspace"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("extra_cargo_test_args")
|
Arg::new("extra_cargo_test_args")
|
||||||
.value_name("extra args for cargo test and the test binary")
|
.value_name("extra args for cargo test and the test binary")
|
||||||
.index(1)
|
.index(1)
|
||||||
.multiple(true)
|
.multiple_occurrences(true)
|
||||||
|
.multiple_values(true)
|
||||||
.help("All extra arguments are passed through to cargo test"),
|
.help("All extra arguments are passed through to cargo test"),
|
||||||
)
|
)
|
||||||
.get_matches_from(args);
|
.get_matches_from(args);
|
||||||
|
|
||||||
let mut config = Config {
|
let mut config = Config {
|
||||||
bpf_sdk: value_t!(matches, "bpf_sdk", String).ok(),
|
bpf_sdk: matches.value_of_t("bpf_sdk").ok(),
|
||||||
bpf_out_dir: value_t!(matches, "bpf_out_dir", String).ok(),
|
bpf_out_dir: matches.value_of_t("bpf_out_dir").ok(),
|
||||||
extra_cargo_test_args: values_t!(matches, "extra_cargo_test_args", String)
|
extra_cargo_test_args: matches
|
||||||
.ok()
|
.values_of_t("extra_cargo_test_args")
|
||||||
.unwrap_or_default(),
|
|
||||||
features: values_t!(matches, "features", String)
|
|
||||||
.ok()
|
.ok()
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
|
features: matches.values_of_t("features").ok().unwrap_or_default(),
|
||||||
generate_child_script_on_failure: matches.is_present("generate_child_script_on_failure"),
|
generate_child_script_on_failure: matches.is_present("generate_child_script_on_failure"),
|
||||||
test_name: value_t!(matches, "test", String).ok(),
|
test_name: matches.value_of_t("test").ok(),
|
||||||
no_default_features: matches.is_present("no_default_features"),
|
no_default_features: matches.is_present("no_default_features"),
|
||||||
no_run: matches.is_present("no_run"),
|
no_run: matches.is_present("no_run"),
|
||||||
offline: matches.is_present("offline"),
|
offline: matches.is_present("offline"),
|
||||||
|
@ -345,6 +344,6 @@ fn main() {
|
||||||
config.extra_cargo_test_args.insert(0, em_dash);
|
config.extra_cargo_test_args.insert(0, em_dash);
|
||||||
}
|
}
|
||||||
|
|
||||||
let manifest_path = value_t!(matches, "manifest_path", PathBuf).ok();
|
let manifest_path: Option<PathBuf> = matches.value_of_t("manifest_path").ok();
|
||||||
test_bpf(config, manifest_path);
|
test_bpf(config, manifest_path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue