Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions kani-driver/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ pub struct KaniArgs {
/// Kani will only compile the crate. No verification will be performed
#[structopt(long, hidden_short_help(true))]
pub only_codegen: bool,
/// Compiles Kani harnesses in all features of all packages selected on the command-line.
#[structopt(long)]
pub all_features: bool,
/// Run Kani on all packages in the workspace.
#[structopt(long)]
pub workspace: bool,
Expand Down
4 changes: 4 additions & 0 deletions kani-driver/src/call_cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ impl KaniSession {
args.push("build".into());
}

if self.args.all_features {
args.push("--all-features".into());
}

if self.args.workspace {
args.push("--workspace".into());
}
Expand Down
18 changes: 18 additions & 0 deletions tests/cargo-kani/feature-flag/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright Kani Contributors
# SPDX-License-Identifier: Apache-2.0 OR MIT

[package]
name = "feature-flag"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
A = []
B = []

[dependencies]

[package.metadata.kani.flags]
all-features = true
1 change: 1 addition & 0 deletions tests/cargo-kani/feature-flag/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3 successfully verified harnesses
21 changes: 21 additions & 0 deletions tests/cargo-kani/feature-flag/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! 3 proof harnesses, 2 of them are feature-gated.

#[kani::proof]
fn check_proof() {
assert!(1 == 1);
}

#[cfg(feature = "A")]
#[kani::proof]
fn check_proof_a() {
assert!(2 == 2);
}

#[cfg(feature = "B")]
#[kani::proof]
fn check_proof_b() {
assert!(3 == 3);
}