Skip to content

Commit 1611824

Browse files
authored
Treat lack of proof harnesses as success (rust-lang#1886)
1 parent 80f5e2c commit 1611824

File tree

6 files changed

+30
-12
lines changed

6 files changed

+30
-12
lines changed

kani-driver/src/harness_runner.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,27 @@ impl KaniSession {
135135
)
136136
}
137137

138-
if !self.args.quiet && !self.args.visualize && total > 1 {
138+
// We currently omit a summary if there was just 1 harness
139+
if !self.args.quiet && !self.args.visualize && total != 1 {
139140
if failing > 0 {
140141
println!("Summary:");
141142
}
142143
for failure in failures.iter() {
143144
println!("Verification failed for - {}", failure.harness.pretty_name);
144145
}
145146

146-
println!(
147-
"Complete - {} successfully verified harnesses, {} failures, {} total.",
148-
succeeding, failing, total
149-
);
147+
if total > 0 {
148+
println!(
149+
"Complete - {} successfully verified harnesses, {} failures, {} total.",
150+
succeeding, failing, total
151+
);
152+
} else {
153+
// TODO: This could use a better error message, possibly with links to Kani documentation.
154+
// New users may encounter this and could use a pointer to how to write proof harnesses.
155+
println!(
156+
"No proof harnesses (functions with #[kani::proof]) were found to verify."
157+
);
158+
}
150159
}
151160

152161
#[cfg(feature = "unsound_experiments")]

kani-driver/src/metadata.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,7 @@ impl KaniSession {
153153
let harness = find_proof_harness(name, &metadata.proof_harnesses)?;
154154
return Ok(vec![harness.clone()]);
155155
}
156-
if metadata.proof_harnesses.is_empty() {
157-
// TODO: This could use a better error message, possibly with links to Kani documentation.
158-
// New users may encounter this and could use a pointer to how to write proof harnesses.
159-
bail!("No proof harnesses (functions with #[kani::proof]) were found to verify.");
160-
} else {
161-
Ok(metadata.proof_harnesses.clone())
162-
}
156+
Ok(metadata.proof_harnesses.clone())
163157
}
164158
}
165159

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
[package]
4+
name = "zero-harnesses-is-success"
5+
version = "0.1.0"
6+
edition = "2021"
7+
8+
[dependencies]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No proof harnesses (functions with #[kani::proof]) were found to verify.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
pub fn nop() {}

tools/compiletest/src/runtest.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ impl<'test> TestCx<'test> {
317317
let proc_res = self.compose_and_run(cargo);
318318
let expected = fs::read_to_string(self.testpaths.file.clone()).unwrap();
319319
self.verify_output(&proc_res, &expected);
320+
321+
// TODO: We should probably be checking the exit status somehow
322+
// See https://github.com/model-checking/kani/issues/1895
320323
}
321324

322325
/// Common method used to run Kani on a single file test.

0 commit comments

Comments
 (0)