Skip to content
Snippets Groups Projects
Commit 55e3fdf5 authored by Per Lindgren's avatar Per Lindgren
Browse files

move to clap 4, wip4, replay almost working

parent 041a348c
No related branches found
No related tags found
No related merge requests found
// Commodity functions to parse the output of `cargo`.
// Notice, this is fragile and depends on the output format of `cargo` which has no stability guarantees.
use regex::Regex;
pub fn get_hash(s: &str) -> Option<String> {
let re = Regex::new(r"(-C metadata=)([\da-f]*)").unwrap();
let cap = re.captures(s)?;
Some(cap[2].to_string())
}
pub fn get_out_dir(s: &str) -> Option<String> {
let re = Regex::new(r"(--out-dir)( )([[:alpha:]\d/-]*)").unwrap();
let cap = re.captures(s)?;
Some(cap[3].to_string())
}
#[test]
fn test_hash() {
let s = "-C linker=true -C lto --emit=llvm-ir -C metadata=71aaac8ea4e4b0e4 extra-filename=-71aaac8ea4e4b0e4 -C metadata=71e4";
let hash = get_hash(s);
println!("hash {:?}", hash);
assert_eq!(hash.unwrap(), "71aaac8ea4e4b0e4");
}
#[test]
fn test_out_dir_bin() {
let s = "-C extra-filename=-6539d757805e64cf --out-dir /home/pln/courses/d7020e/cargo-klee/klee-examples/target/debug/examples -L dependency=/home/pln/courses/d7020e/cargo-klee/klee-examples/target/debug/deps";
let dir = get_out_dir(s);
println!("dir {:?}", dir);
assert_eq!(
dir.unwrap(),
"/home/pln/courses/d7020e/cargo-klee/klee-examples/target/debug/examples"
);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment