Skip to content

Commit a301de1

Browse files
authored
Refactor Assess table building, introduce TableBuilder. (rust-lang#2014)
1 parent 6fe52d7 commit a301de1

File tree

6 files changed

+539
-270
lines changed

6 files changed

+539
-270
lines changed

kani-driver/src/assess.rs

Lines changed: 0 additions & 270 deletions
This file was deleted.

kani-driver/src/assess/mod.rs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
use anyhow::Result;
5+
6+
use crate::metadata::merge_kani_metadata;
7+
use crate::project;
8+
use crate::session::KaniSession;
9+
10+
mod table_builder;
11+
mod table_failure_reasons;
12+
mod table_promising_tests;
13+
mod table_unsupported_features;
14+
15+
pub(crate) fn cargokani_assess_main(mut session: KaniSession) -> Result<()> {
16+
// fix some settings
17+
session.args.unwind = Some(1);
18+
session.args.tests = true;
19+
session.args.output_format = crate::args::OutputFormat::Terse;
20+
session.codegen_tests = true;
21+
if session.args.jobs.is_none() {
22+
// assess will default to fully parallel instead of single-threaded.
23+
// can be overridden with e.g. `cargo kani --enable-unstable -j 8 assess`
24+
session.args.jobs = Some(None); // -j, num_cpu
25+
}
26+
27+
let project = project::cargo_project(&session)?;
28+
29+
let crate_count = project.metadata.len();
30+
31+
// An interesting thing to print here would be "number of crates without any warnings"
32+
// however this will have to wait until a refactoring of how we aggregate metadata
33+
// from multiple crates together here.
34+
// tracking for that: https://github.com/model-checking/kani/issues/1758
35+
println!("Analyzed {crate_count} crates");
36+
37+
let metadata = merge_kani_metadata(project.metadata.clone());
38+
if !metadata.unsupported_features.is_empty() {
39+
println!("{}", table_unsupported_features::build(&metadata));
40+
} else {
41+
println!("No crates contained Rust features unsupported by Kani");
42+
}
43+
44+
if session.args.only_codegen {
45+
return Ok(());
46+
}
47+
48+
// Done with the 'cargo-kani' part, now we're going to run *test* harnesses instead of proof:
49+
let harnesses = metadata.test_harnesses;
50+
let runner = crate::harness_runner::HarnessRunner { sess: &session, project };
51+
52+
let results = runner.check_all_harnesses(&harnesses)?;
53+
54+
// two tables we want to print:
55+
// 1. "Reason for failure" will count reasons why harnesses did not succeed
56+
// e.g. successs 6
57+
// unwind 234
58+
println!("{}", table_failure_reasons::build(&results));
59+
60+
// TODO: Should add another interesting table: Count the actually hit constructs (e.g. 'try', 'InlineAsm', etc)
61+
// The above table will just say "unsupported_construct 6" without telling us which constructs.
62+
// Tracking issue: https://github.com/model-checking/kani/issues/1819
63+
64+
// 2. "Test cases that might be good proof harness starting points"
65+
// e.g. All Successes and maybe Assertions?
66+
println!("{}", table_promising_tests::build(&results));
67+
68+
Ok(())
69+
}

0 commit comments

Comments
 (0)