Skip to content

Commit 7de0c1b

Browse files
committed
Print in alphabetical order
1 parent 65b3819 commit 7de0c1b

File tree

7 files changed

+100
-97
lines changed

7 files changed

+100
-97
lines changed

kani-compiler/src/kani_middle/codegen_units.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,11 @@ impl CodegenUnits {
9292
args,
9393
*kani_fns.get(&KaniModel::Any.into()).unwrap(),
9494
);
95-
let chosen_fn_names = chosen.iter().map(|func| func.name()).collect::<Vec<_>>();
9695
AUTOHARNESS_MD
97-
.set(AutoHarnessMetadata { chosen: chosen_fn_names, skipped })
96+
.set(AutoHarnessMetadata {
97+
chosen: chosen.iter().map(|func| func.name()).collect::<BTreeSet<_>>(),
98+
skipped,
99+
})
98100
.expect("Initializing the autoharness metdata failed");
99101

100102
let automatic_harnesses = get_all_automatic_harnesses(

kani-driver/src/autoharness/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ impl KaniSession {
178178
}
179179

180180
/// Prints the results from running the `autoharness` subcommand.
181-
pub fn print_autoharness_summary(&self, automatic: Vec<&HarnessResult<'_>>) -> Result<()> {
181+
pub fn print_autoharness_summary(&self, mut automatic: Vec<&HarnessResult<'_>>) -> Result<()> {
182+
automatic.sort_by(|a, b| a.harness.pretty_name.cmp(&b.harness.pretty_name));
182183
let (successes, failures): (Vec<_>, Vec<_>) =
183184
automatic.into_iter().partition(|r| r.result.status == VerificationStatus::Success);
184185

kani_metadata/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate clap;
55

66
use serde::{Deserialize, Serialize};
77
use std::{
8-
collections::{BTreeMap, HashSet},
8+
collections::{BTreeMap, BTreeSet, HashSet},
99
path::PathBuf,
1010
};
1111
use strum_macros::{Display, EnumString};
@@ -43,12 +43,12 @@ pub struct KaniMetadata {
4343

4444
/// For the autoharness subcommand, all of the user-defined functions we found,
4545
/// which are "chosen" if we generated an automatic harness for them, and "skipped" otherwise.
46+
/// We use ordered data structures so that the metadata is in alphabetical order.
4647
#[derive(Debug, Clone, Serialize, Deserialize)]
4748
pub struct AutoHarnessMetadata {
4849
/// Functions we generated automatic harnesses for.
49-
pub chosen: Vec<String>,
50+
pub chosen: BTreeSet<String>,
5051
/// Map function names to the reason why we did not generate an automatic harness for that function.
51-
/// We use an ordered map so that when we print the data, it is ordered alphabetically by function name.
5252
pub skipped: BTreeMap<String, AutoHarnessSkipReason>,
5353
}
5454

tests/script-based-pre/cargo_autoharness_contracts/contracts.expected

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ Kani generated automatic harnesses for 5 function(s):
22
+--------------------------------+
33
| Selected Function |
44
+================================+
5-
| should_pass::div |
5+
| should_fail::max |
66
|--------------------------------|
7-
| should_pass::has_recursion_gcd |
7+
| should_pass::div |
88
|--------------------------------|
99
| should_pass::has_loop_contract |
1010
|--------------------------------|
11-
| should_pass::unchecked_mul |
11+
| should_pass::has_recursion_gcd |
1212
|--------------------------------|
13-
| should_fail::max |
13+
| should_pass::unchecked_mul |
1414
+--------------------------------+
1515

1616
Skipped Functions: None. Kani generated automatic harnesses for all functions in the available crate(s).
@@ -44,13 +44,13 @@ Autoharness Summary:
4444
+--------------------------------+-----------------------------+---------------------+
4545
| Selected Function | Kind of Automatic Harness | Verification Result |
4646
+====================================================================================+
47-
| should_pass::unchecked_mul | #[kani::proof_for_contract] | Success |
47+
| should_pass::div | #[kani::proof_for_contract] | Success |
4848
|--------------------------------+-----------------------------+---------------------|
4949
| should_pass::has_loop_contract | #[kani::proof] | Success |
5050
|--------------------------------+-----------------------------+---------------------|
5151
| should_pass::has_recursion_gcd | #[kani::proof_for_contract] | Success |
5252
|--------------------------------+-----------------------------+---------------------|
53-
| should_pass::div | #[kani::proof_for_contract] | Success |
53+
| should_pass::unchecked_mul | #[kani::proof_for_contract] | Success |
5454
|--------------------------------+-----------------------------+---------------------|
5555
| should_fail::max | #[kani::proof_for_contract] | Failure |
5656
+--------------------------------+-----------------------------+---------------------+

0 commit comments

Comments
 (0)