Skip to content

Commit efd082c

Browse files
Implement -p flag for running kani on specific package (rust-lang#1559)
* Implement -p / --package flag. * Fixed comments. * Modified tests to check running 2/3 tests. 1/2 does not show up in a way that we can check! * Fixed -p to match build: multiple packages allowed. * Forced one of the active packages to fail, enforce expected * Changed name of test
1 parent efdb0b2 commit efd082c

File tree

11 files changed

+98
-0
lines changed

11 files changed

+98
-0
lines changed

kani-driver/src/args.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ pub struct KaniArgs {
121121
/// Run Kani on all packages in the workspace.
122122
#[structopt(long)]
123123
pub workspace: bool,
124+
/// Run Kani on the specified packages.
125+
#[structopt(long, short)]
126+
pub package: Vec<String>,
124127

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

kani-driver/src/call_cargo.rs

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

55+
for package in self.args.package.iter() {
56+
args.push("--package".into());
57+
args.push(package.into());
58+
}
59+
5560
if self.args.all_features {
5661
args.push("--all-features".into());
5762
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
[package]
5+
name = "topcrate"
6+
version = "0.1.0"
7+
edition = "2021"
8+
9+
[workspace]
10+
members = [
11+
"libcrate",
12+
"bincrate",
13+
"subcrate3",
14+
]
15+
16+
[package.metadata.kani.flags]
17+
package = ["libcrate", "bincrate"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
[package]
5+
name = "bincrate"
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]
12+
libcrate = { path = "../libcrate" }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
//! One of 3 sub packages used to test specifying packages with -p
5+
//! flag.
6+
7+
fn main() {
8+
println!("Hello, world!");
9+
}
10+
11+
#[kani::proof]
12+
fn check_bincrate_proof() {
13+
assert!(1 == 1);
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Complete - 1 successfully verified harnesses, 1 failures, 2 total.
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
//! One of 3 sub packages used to test specifying packages with -p
5+
//! flag.
6+
7+
#[kani::proof]
8+
fn check_libcrate_proof() {
9+
assert!(1 == 2);
10+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
//! empty lib for toplevel directory
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 = "subcrate3"
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
//! One of 3 sub packages used to test specifying packages with -p
5+
//! flag.
6+
7+
#[kani::proof]
8+
fn check_subcrate3_proof() {
9+
assert!(1 == 1);
10+
}

0 commit comments

Comments
 (0)