Skip to content

Commit fbf0533

Browse files
authored
Fix cargo kani --debug and remove debug logs from --verbose (rust-lang#1730)
- Fix rust-lang#1348: Fix `cargo kani --debug` by redirecting kani-compiler logs to the STDERR so it doesn't conflict with cargo's output expectations. - Fix rust-lang#1631: Remove `kani-compiler` logs from the output of `--verbose`.
1 parent 35b4b10 commit fbf0533

File tree

9 files changed

+49
-4
lines changed

9 files changed

+49
-4
lines changed

kani-compiler/src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fn hier_logs(args: &ArgMatches, filter: EnvFilter) {
8181
let subscriber = Registry::default().with(filter);
8282
let subscriber = subscriber.with(
8383
HierarchicalLayer::default()
84-
.with_writer(std::io::stdout)
84+
.with_writer(std::io::stderr)
8585
.with_indent_lines(true)
8686
.with_ansi(use_colors)
8787
.with_targets(true)

kani-driver/src/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub struct KaniArgs {
6969
#[structopt(long, short)]
7070
pub quiet: bool,
7171
/// Output processing stages and commands, along with minor debug information
72-
#[structopt(long, short)]
72+
#[structopt(long, short, default_value_if("debug", None, "true"), min_values(0))]
7373
pub verbose: bool,
7474
/// Enable usage of unstable options
7575
#[structopt(long, hidden_short_help(true))]

kani-driver/src/call_single_file.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ impl KaniSession {
107107

108108
if self.args.debug {
109109
flags.push("--log-level=debug".into());
110-
} else if self.args.verbose {
111-
flags.push("--log-level=info".into());
112110
} else {
113111
flags.push("--log-level=warn".into());
114112
}

tests/cargo-ui/debug/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
[package]
4+
name = "debug"
5+
version = "0.1.0"
6+
edition = "2021"
7+
8+
[dependencies]
9+
10+
[package.metadata.kani.flags]
11+
debug=true

tests/cargo-ui/debug/expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DEBUG kani_compiler
2+
goto-cc
3+
cbmc

tests/cargo-ui/debug/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
//
4+
//! This is just to test that cargo kani --debug works.
5+
6+
#[cfg(kani)]
7+
mod harnesses {
8+
#[kani::proof]
9+
fn harness() {}
10+
}

tests/cargo-ui/verbose/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright Kani Contributors
2+
# SPDX-License-Identifier: Apache-2.0 OR MIT
3+
[package]
4+
name = "verbose"
5+
version = "0.1.0"
6+
edition = "2021"
7+
8+
[dependencies]
9+
10+
[package.metadata.kani.flags]
11+
verbose=true

tests/cargo-ui/verbose/expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
goto-cc
2+
cbmc

tests/cargo-ui/verbose/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
//
4+
//! This is just to test that cargo kani --verbose works.
5+
6+
#[cfg(kani)]
7+
mod harnesses {
8+
#[kani::proof]
9+
fn harness() {}
10+
}

0 commit comments

Comments
 (0)