1
0
mirror of https://github.com/ellmau/adf-obdd.git synced 2025-12-19 09:29:36 +01:00

UPD clap, FIX resulting issues (#26)

Update clap to version 3.1.3, so
- structopt gets obsolete
- Errors are differently named, therefore tests needed to be adapted
- updated Cargo.lock for the binary

Fixed an issue with clippy warnings
This commit is contained in:
Stefan Ellmauthaler 2022-03-01 15:32:57 +01:00 committed by GitHub
parent b18bbe0ed4
commit a2fa3adfe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 116 additions and 48 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
# Generated by Cargo # Generated by Cargo
# will have compiled files and executables # will have compiled files and executables
/target/ /target/
/bin/target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html

106
bin/Cargo.lock generated
View File

@ -4,12 +4,12 @@ version = 3
[[package]] [[package]]
name = "adf_bdd" name = "adf_bdd"
version = "0.2.0" version = "0.2.1"
dependencies = [ dependencies = [
"adf_bdd 0.2.0 (git+https://github.com/ellmau/adf-obdd?branch=main)", "adf_bdd 0.2.1 (git+https://github.com/ellmau/adf-obdd?branch=main)",
"assert_cmd", "assert_cmd",
"assert_fs", "assert_fs",
"clap", "clap 3.1.3",
"env_logger", "env_logger",
"log", "log",
"predicates", "predicates",
@ -20,19 +20,16 @@ dependencies = [
[[package]] [[package]]
name = "adf_bdd" name = "adf_bdd"
version = "0.2.0" version = "0.2.1"
source = "git+https://github.com/ellmau/adf-obdd?branch=main#565fef99d127ffce7b966740a2b8a9b03ab67934" source = "git+https://github.com/ellmau/adf-obdd?branch=main#b18bbe0ed4755f03e5878ecc7ef87ffc7fc71bce"
dependencies = [ dependencies = [
"biodivine-lib-bdd", "biodivine-lib-bdd",
"clap",
"derivative", "derivative",
"env_logger",
"lexical-sort", "lexical-sort",
"log", "log",
"nom", "nom",
"serde", "serde",
"serde_json", "serde_json",
"structopt",
] ]
[[package]] [[package]]
@ -46,9 +43,9 @@ dependencies = [
[[package]] [[package]]
name = "ansi_term" name = "ansi_term"
version = "0.11.0" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [ dependencies = [
"winapi", "winapi",
] ]
@ -145,19 +142,49 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "2.33.4" version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "826bf7bc84f9435630275cb8e802a4a0ec792b615969934bd16d42ffed10f207" checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [ dependencies = [
"ansi_term", "ansi_term",
"atty", "atty",
"bitflags", "bitflags",
"strsim", "strsim 0.8.0",
"textwrap", "textwrap 0.11.0",
"unicode-width", "unicode-width",
"vec_map", "vec_map",
] ]
[[package]]
name = "clap"
version = "3.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f8c0e2a6b902acc18214e24a6935cdaf8a8e34231913d4404dcaee659f65a1"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"indexmap",
"lazy_static",
"os_str_bytes",
"strsim 0.10.0",
"termcolor",
"textwrap 0.14.2",
]
[[package]]
name = "clap_derive"
version = "3.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01d42c94ce7c2252681b5fed4d3627cc807b13dfc033246bd05d5b252399000e"
dependencies = [
"heck 0.4.0",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.7" version = "0.8.7"
@ -278,6 +305,12 @@ dependencies = [
"walkdir", "walkdir",
] ]
[[package]]
name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
[[package]] [[package]]
name = "heck" name = "heck"
version = "0.3.3" version = "0.3.3"
@ -287,6 +320,12 @@ dependencies = [
"unicode-segmentation", "unicode-segmentation",
] ]
[[package]]
name = "heck"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.19" version = "0.1.19"
@ -320,6 +359,16 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "indexmap"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]] [[package]]
name = "instant" name = "instant"
version = "0.1.12" version = "0.1.12"
@ -418,6 +467,15 @@ version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
[[package]]
name = "os_str_bytes"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.16" version = "0.2.16"
@ -539,9 +597,9 @@ dependencies = [
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.2.10" version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c"
dependencies = [ dependencies = [
"bitflags", "bitflags",
] ]
@ -630,13 +688,19 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "strsim"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "structopt" name = "structopt"
version = "0.3.26" version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10"
dependencies = [ dependencies = [
"clap", "clap 2.34.0",
"lazy_static", "lazy_static",
"structopt-derive", "structopt-derive",
] ]
@ -647,7 +711,7 @@ version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
dependencies = [ dependencies = [
"heck", "heck 0.3.3",
"proc-macro-error", "proc-macro-error",
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -703,6 +767,12 @@ dependencies = [
"unicode-width", "unicode-width",
] ]
[[package]]
name = "textwrap"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
[[package]] [[package]]
name = "thread_local" name = "thread_local"
version = "1.1.4" version = "1.1.4"

View File

@ -11,8 +11,7 @@ description = "Solver for ADFs grounded, complete, and stable semantics by utili
[dependencies] [dependencies]
adf_bdd = { git = "https://github.com/ellmau/adf-obdd", branch = "main" } adf_bdd = { git = "https://github.com/ellmau/adf-obdd", branch = "main" }
clap = "2.33.*" clap = {version = "3.1.3", features = [ "derive", "cargo", "env" ]}
structopt = "0.3.25"
log = { version = "0.4", features = [ "max_level_trace", "release_max_level_info" ] } log = { version = "0.4", features = [ "max_level_trace", "release_max_level_info" ] }
serde = { version = "1.0", features = ["derive","rc"] } serde = { version = "1.0", features = ["derive","rc"] }
serde_json = "1.0" serde_json = "1.0"

View File

@ -69,60 +69,58 @@ use adf_bdd::adf::Adf;
use adf_bdd::adfbiodivine::Adf as BdAdf; use adf_bdd::adfbiodivine::Adf as BdAdf;
use adf_bdd::parser::AdfParser; use adf_bdd::parser::AdfParser;
use clap::{crate_authors, crate_description, crate_name, crate_version}; use clap::Parser;
use structopt::StructOpt; #[derive(Parser, Debug)]
#[clap(author, version, about)]
#[derive(StructOpt, Debug)]
#[structopt(name = crate_name!(), about = crate_description!(), author = crate_authors!(), version = crate_version!())]
struct App { struct App {
/// Input filename /// Input filename
#[structopt(parse(from_os_str))] #[clap(parse(from_os_str))]
input: PathBuf, input: PathBuf,
/// Sets the verbosity to 'warn', 'info', 'debug' or 'trace' if -v and -q are not use /// Sets the verbosity to 'warn', 'info', 'debug' or 'trace' if -v and -q are not use
#[structopt(long = "rust_log", env)] #[clap(long = "rust_log", env)]
rust_log: Option<String>, rust_log: Option<String>,
/// choose the bdd implementation of either 'biodivine', 'naive', or hybrid /// choose the bdd implementation of either 'biodivine', 'naive', or hybrid
#[structopt(long = "lib", default_value = "biodivine")] #[clap(long = "lib", default_value = "biodivine")]
implementation: String, implementation: String,
/// Sets log verbosity (multiple times means more verbose) /// Sets log verbosity (multiple times means more verbose)
#[structopt(short, parse(from_occurrences), group = "verbosity")] #[clap(short, parse(from_occurrences), group = "verbosity")]
verbose: u8, verbose: u8,
/// Sets log verbosity to only errors /// Sets log verbosity to only errors
#[structopt(short, group = "verbosity")] #[clap(short, group = "verbosity")]
quiet: bool, quiet: bool,
/// Sorts variables in an lexicographic manner /// Sorts variables in an lexicographic manner
#[structopt(long = "lx", group = "sorting")] #[clap(long = "lx", group = "sorting")]
sort_lex: bool, sort_lex: bool,
/// Sorts variables in an alphanumeric manner /// Sorts variables in an alphanumeric manner
#[structopt(long = "an", group = "sorting")] #[clap(long = "an", group = "sorting")]
sort_alphan: bool, sort_alphan: bool,
/// Compute the grounded model /// Compute the grounded model
#[structopt(long = "grd")] #[clap(long = "grd")]
grounded: bool, grounded: bool,
/// Compute the stable models /// Compute the stable models
#[structopt(long = "stm")] #[clap(long = "stm")]
stable: bool, stable: bool,
/// Compute the stable models with a pre-filter (only hybrid lib-mode) /// Compute the stable models with a pre-filter (only hybrid lib-mode)
#[structopt(long = "stmpre")] #[clap(long = "stmpre")]
stable_pre: bool, stable_pre: bool,
/// Compute the stable models with a single-formula rewriting (only hybrid lib-mode) /// Compute the stable models with a single-formula rewriting (only hybrid lib-mode)
#[structopt(long = "stmrew")] #[clap(long = "stmrew")]
stable_rew: bool, stable_rew: bool,
/// Compute the stable models with a single-formula rewriting on internal representation(only hybrid lib-mode) /// Compute the stable models with a single-formula rewriting on internal representation(only hybrid lib-mode)
#[structopt(long = "stmrew2")] #[clap(long = "stmrew2")]
stable_rew2: bool, stable_rew2: bool,
/// Compute the complete models /// Compute the complete models
#[structopt(long = "com")] #[clap(long = "com")]
complete: bool, complete: bool,
/// Import an adf- bdd state instead of an adf /// Import an adf- bdd state instead of an adf
#[structopt(long)] #[clap(long)]
import: bool, import: bool,
/// Export the adf-bdd state after parsing and BDD instantiation to the given filename /// Export the adf-bdd state after parsing and BDD instantiation to the given filename
#[structopt(long)] #[clap(long)]
export: Option<PathBuf>, export: Option<PathBuf>,
/// Set if the (counter-)models shall be computed and printed, possible values are 'nai' and 'mem' for naive and memoization repectively (only works in hybrid and naive mode) /// Set if the (counter-)models shall be computed and printed, possible values are 'nai' and 'mem' for naive and memoization repectively (only works in hybrid and naive mode)
#[structopt(long)] #[clap(long)]
counter: Option<String>, counter: Option<String>,
} }
@ -149,7 +147,7 @@ impl App {
} }
}; };
env_logger::builder().filter_level(filter_level).init(); env_logger::builder().filter_level(filter_level).init();
log::info!("Version: {}", crate_version!()); log::info!("Version: {}", clap::crate_version!());
let input = std::fs::read_to_string(self.input.clone()).expect("Error Reading File"); let input = std::fs::read_to_string(self.input.clone()).expect("Error Reading File");
match self.implementation.as_str() { match self.implementation.as_str() {
"hybrid" => { "hybrid" => {
@ -344,6 +342,6 @@ impl App {
} }
fn main() { fn main() {
let app = App::from_args(); let app = App::parse();
app.run(); app.run();
} }

View File

@ -14,7 +14,7 @@ fn arguments() -> Result<(), Box<dyn std::error::Error>> {
cmd = Command::cargo_bin("adf_bdd")?; cmd = Command::cargo_bin("adf_bdd")?;
cmd.arg("-v").arg("--lx").arg("--an").arg("file.txt"); cmd.arg("-v").arg("--lx").arg("--an").arg("file.txt");
cmd.assert().failure().stderr(predicate::str::contains( cmd.assert().failure().stderr(predicate::str::contains(
"cannot be used with one or more of the other specified arguments", "The argument '--lx' cannot be used with '--an'",
)); ));
cmd = Command::cargo_bin("adf_bdd")?; cmd = Command::cargo_bin("adf_bdd")?;

View File

@ -31,9 +31,9 @@ fn write_test(test_file: &mut File, file: &DirEntry) {
let file = file.path().canonicalize().unwrap(); let file = file.path().canonicalize().unwrap();
let path = file.display(); let path = file.display();
let test_name = format!("{}", file.file_name().unwrap().to_string_lossy()) let test_name = format!("{}", file.file_name().unwrap().to_string_lossy())
.replace(".", "_") .replace('.', "_")
.replace("-", "_") .replace('-', "_")
.replace("@", "at") .replace('@', "at")
.to_lowercase(); .to_lowercase();
let grounded_name = format!( let grounded_name = format!(
"{}-grounded.txt", "{}-grounded.txt",

View File

@ -450,7 +450,7 @@ mod test {
let serialized = serde_json::to_string(&adf).unwrap(); let serialized = serde_json::to_string(&adf).unwrap();
log::debug!("Serialized to {}", serialized); log::debug!("Serialized to {}", serialized);
let result = r#"{"ordering":{"names":["a","c","b","e","d"],"mapping":{"b":2,"a":0,"c":1,"e":3,"d":4}},"bdd":{"nodes":[{"var":18446744073709551614,"lo":0,"hi":0},{"var":18446744073709551615,"lo":1,"hi":1},{"var":0,"lo":0,"hi":1},{"var":1,"lo":0,"hi":1},{"var":2,"lo":0,"hi":1},{"var":3,"lo":0,"hi":1},{"var":4,"lo":0,"hi":1},{"var":0,"lo":1,"hi":0},{"var":0,"lo":1,"hi":4},{"var":1,"lo":1,"hi":0},{"var":2,"lo":1,"hi":0},{"var":1,"lo":10,"hi":4},{"var":0,"lo":3,"hi":11},{"var":3,"lo":1,"hi":0},{"var":4,"lo":1,"hi":0},{"var":3,"lo":6,"hi":14}],"cache":[[{"var":1,"lo":0,"hi":1},3],[{"var":3,"lo":6,"hi":14},15],[{"var":2,"lo":0,"hi":1},4],[{"var":0,"lo":1,"hi":0},7],[{"var":0,"lo":3,"hi":11},12],[{"var":3,"lo":1,"hi":0},13],[{"var":4,"lo":1,"hi":0},14],[{"var":0,"lo":0,"hi":1},2],[{"var":3,"lo":0,"hi":1},5],[{"var":0,"lo":1,"hi":4},8],[{"var":4,"lo":0,"hi":1},6],[{"var":1,"lo":1,"hi":0},9],[{"var":2,"lo":1,"hi":0},10],[{"var":1,"lo":10,"hi":4},11]],"count_cache":{}},"ac":[4,2,7,15,12]}"#; let result = r#"{"ordering":{"names":["a","c","b","e","d"],"mapping":{"b":2,"a":0,"c":1,"e":3,"d":4}},"bdd":{"nodes":[{"var":18446744073709551614,"lo":0,"hi":0},{"var":18446744073709551615,"lo":1,"hi":1},{"var":0,"lo":0,"hi":1},{"var":1,"lo":0,"hi":1},{"var":2,"lo":0,"hi":1},{"var":3,"lo":0,"hi":1},{"var":4,"lo":0,"hi":1},{"var":0,"lo":1,"hi":0},{"var":0,"lo":1,"hi":4},{"var":1,"lo":1,"hi":0},{"var":2,"lo":1,"hi":0},{"var":1,"lo":10,"hi":4},{"var":0,"lo":3,"hi":11},{"var":3,"lo":1,"hi":0},{"var":4,"lo":1,"hi":0},{"var":3,"lo":6,"hi":14}],"cache":[[{"var":1,"lo":0,"hi":1},3],[{"var":3,"lo":6,"hi":14},15],[{"var":2,"lo":0,"hi":1},4],[{"var":0,"lo":1,"hi":0},7],[{"var":0,"lo":3,"hi":11},12],[{"var":3,"lo":1,"hi":0},13],[{"var":4,"lo":1,"hi":0},14],[{"var":0,"lo":0,"hi":1},2],[{"var":3,"lo":0,"hi":1},5],[{"var":0,"lo":1,"hi":4},8],[{"var":4,"lo":0,"hi":1},6],[{"var":1,"lo":1,"hi":0},9],[{"var":2,"lo":1,"hi":0},10],[{"var":1,"lo":10,"hi":4},11]],"count_cache":{}},"ac":[4,2,7,15,12]}"#;
let mut deserialized: Adf = serde_json::from_str(&result).unwrap(); let mut deserialized: Adf = serde_json::from_str(result).unwrap();
assert_eq!(adf.ac, deserialized.ac); assert_eq!(adf.ac, deserialized.ac);
let grounded_import = deserialized.grounded(); let grounded_import = deserialized.grounded();