Skip to content

Commit

Permalink
Added --all-features flag. (#1532)
Browse files Browse the repository at this point in the history
* Added --all-features flag.

* Made the doc more detailed.
  • Loading branch information
YoshikiTakashima authored Aug 18, 2022
1 parent 298002d commit cf76024
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
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);
}

0 comments on commit cf76024

Please sign in to comment.