Skip to content

Commit 1b457e4

Browse files
committed
lib: kani_path consider $KANI_DIR or kani's own path settings
1 parent ac2f28f commit 1b457e4

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/lib.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,21 @@ pub struct Callee {
2626
}
2727

2828
/// A local path to kani's artifacts.
29+
///
30+
/// Choose the following if found
31+
/// * `$KANI_DIR`
32+
/// * or `$KANI_HOME/kani-{version}`
33+
/// * or `$HOME/.kani/kani-{version}`
2934
pub fn kani_path() -> String {
30-
let kani = std::process::Command::new("kani").arg("--version").output().unwrap();
31-
let kani_folder = std::str::from_utf8(&kani.stdout).unwrap().trim().replace(' ', "-");
32-
33-
let home = std::env::var("HOME").unwrap();
34-
let path = format!("{home}/.kani/{kani_folder}");
35+
use std::env::var;
36+
let path = if let Ok(path) = var("KANI_DIR") {
37+
path
38+
} else {
39+
let kani = std::process::Command::new("kani").arg("--version").output().unwrap();
40+
let kani_folder = std::str::from_utf8(&kani.stdout).unwrap().trim().replace(' ', "-");
41+
let home = var("KANI_HOME").or_else(|_| var("HOME")).unwrap();
42+
format!("{home}/.kani/{kani_folder}")
43+
};
44+
assert!(std::fs::exists(&path).unwrap());
3545
path
3646
}

tests/proofs.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ fn test_proofs() -> eyre::Result<()> {
3333

3434
#[test]
3535
/// Make sure latest kani is installed through cargo.
36-
/// FIXME: we'll install kani from source code to keep rust-toolchain sync.
3736
fn kani_installed() {
3837
let path = distributed_verification::kani_path();
3938
dbg!(&path);
40-
assert!(std::fs::exists(path).unwrap());
4139
}

0 commit comments

Comments
 (0)