Skip to content

Commit 787ef7f

Browse files
author
Yoshiki Takashima
authored
Add --workspace to cargo kani. (rust-lang#1530)
* Added workspace flag and tests. * Added license, adjusted comments. * Fixed docs.
1 parent 0115f7d commit 787ef7f

File tree

7 files changed

+57
-0
lines changed

7 files changed

+57
-0
lines changed

kani-driver/src/args.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ pub struct KaniArgs {
114114
/// Kani will only compile the crate. No verification will be performed
115115
#[structopt(long, hidden_short_help(true))]
116116
pub only_codegen: bool,
117+
/// Run Kani on all packages in the workspace.
118+
#[structopt(long)]
119+
pub workspace: bool,
117120

118121
/// Specify the value used for loop unwinding in CBMC
119122
#[structopt(long)]

kani-driver/src/call_cargo.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ impl KaniSession {
5252
args.push("build".into());
5353
}
5454

55+
if self.args.workspace {
56+
args.push("--workspace".into());
57+
}
58+
5559
args.push("--target".into());
5660
args.push(build_target.into());
5761

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
[package]
5+
name = "ws-flag"
6+
version = "0.1.0"
7+
edition = "2021"
8+
9+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
10+
11+
[workspace]
12+
members = [
13+
"libcrate",
14+
]
15+
16+
17+
[dependencies]
18+
19+
[package.metadata.kani.flags]
20+
workspace = true

tests/cargo-kani/ws-flag/expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2 successfully verified harnesses
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
[package]
5+
name = "libcrate"
6+
version = "0.1.0"
7+
edition = "2021"
8+
9+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
10+
11+
[dependencies]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
//! test in sub-crate.
5+
6+
#[kani::proof]
7+
fn check_libcrate_proof() {
8+
assert!(1 == 1);
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
//! test in top crate.
5+
6+
#[kani::proof]
7+
fn check_toplevel_proof() {
8+
assert!(1 == 1);
9+
}

0 commit comments

Comments
 (0)