Skip to content

Report the failure exit code under --quiet - #4771

Merged
feliperodri merged 9 commits into
model-checking:mainfrom
ivmat:fix-quiet-exit-code
Sep 30, 2026
Merged

feliperodri merged 9 commits into
model-checking:mainfrom
ivmat:fix-quiet-exit-code

Conversation

@ivmat

@ivmat ivmat commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #4745.

--quiet's help text promises "Produces no output, just an exit code and requested artifacts", but
print_final_summary returned early under --quiet, before the exit(1) that reports failures, so a
failing verification run exited 0.

This separates printing from the exit decision:

  • verify_project skips print_final_summary under --quiet; print_final_summary only prints.
  • A new conclude step always runs and exits with code 1 if any harness, manual or automatic, failed.
    Under --quiet it also raises the zero-match --harness error that print_final_summary raises otherwise.
  • print_autoharness_summary only prints; it no longer returns a failure count.

Without --quiet, output and exit codes are unchanged.

Behavior under --quiet, before → after

  • Failing manual run: exit 0 → exit 1 (the bug).
  • Failing autoharness run: exit 0 → exit 1 (same root cause).
  • Passing run: exit 0 → exit 0 (unchanged), still no output.
  • kani autoharness --harness <name matching no manual harness>: exit 0 with no output → the no-match
    error on stdout and a non-zero exit, as the zero-match error from determine_targets already does under
    --quiet.

Test

Extends tests/script-based-pre/check-quiet: a passing harness must produce no output and exit 0, and a
failing harness must produce no output and exit 1. It counts the bytes of stdout and stderr together, so
any output fails the test. The autoharness cases above follow from the same conclude code path and are
not tested separately.

@ivmat
ivmat requested review from a team as code owners August 27, 2026 20:22
`--quiet`'s help text promises "no output, just an exit code and requested
artifacts", but `print_final_summary` returned early under `--quiet` before
reaching the `exit(1)` that reports failures, so a failing verification run
exited 0. Nothing else set the failure exit code.

Suppress only the summary output under `--quiet`: compute the failure counts
unconditionally and keep the exit code and error returns identical to a
non-quiet run. `print_autoharness_summary` takes a `quiet` flag so it still
reports its failure count without printing the summary; this also fixes the
same bug for `autoharness --quiet`, whose failure count previously never
reached the exit code.

Add a regression test that runs a failing harness under `--quiet` and asserts
exit 1, plus a passing-run control asserting exit 0 -- the existing check-quiet
test only ran passing harnesses and never inspected the exit code.

Resolves model-checking#4745
@ivmat
ivmat force-pushed the fix-quiet-exit-code branch from 0d20f68 to 7644203 Compare August 27, 2026 20:56
@ivmat

ivmat commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

earlier CI red was kani-fmt --check wanting a println! collapsed

@celinval celinval left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good catch. Thanks for taking the time.

Comment thread kani-driver/src/harness_runner.rs Resolved
Comment thread kani-driver/src/autoharness/mod.rs Resolved
Comment thread kani-driver/src/harness_runner.rs Resolved
Address review: separate the compute (partition into successes/failing,
now behind an autoharness_result() that folds in the
autoharness_compiler_flags.is_some() check) from the print
(print_autoharness_summary, now a pure void function with no quiet
param and no returned count). print_final_summary computes the
autoharness result unconditionally and gates only the print on
!quiet, then derives the exit code from failing + the computed
failing count, unchanged from before. Also drops the now-superfluous
comment block above print_final_summary.
Comment thread kani-driver/src/harness_runner.rs Resolved
Split the exit-code decision out of print_final_summary into a new
conclude step that always runs, and skip the summary print at the call
site when --quiet is set (review feedback).
Comment thread kani-driver/src/harness_runner.rs Resolved
@feliperodri feliperodri assigned ivmat and unassigned celinval Sep 29, 2026
…quiet

Address review nits: conclude counts non-successful results directly, so
the autoharness_result/AutoharnessResult split is no longer needed and
print_autoharness_summary goes back to taking the automatic results,
returning nothing. print_final_summary keeps upstream's zero-match arm, so
output without --quiet is unchanged; conclude repeats that check for the
--quiet path. The check-quiet success line now matches the exact exit code
the test requires, and the output check counts bytes so that newline-only
output also fails. Also trim the comments this PR added.
auto-merge was automatically disabled September 29, 2026 19:34

Head branch was pushed to by a user without write access

@ivmat

ivmat commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@tautschnig updated all. ps found checking the zero match path, not sure if known issue. made no sense to fix it as part of this pr, but if needed can do a separate pr if needed...
on a debug build, any --harness filter under autoharness panics in determine_targets (kani-driver/src/metadata.rs:108), when at least one automatic harness is generated:

fn add(a: u8, b: u8) -> u8 {
    a.wrapping_add(b)
}

#[kani::proof]
fn manual() {
    assert!(add(1, 1) == 2);
}

kani autoharness -Z autoharness repro.rs verifies both and exits 0.
kani autoharness -Z autoharness repro.rs --harness manual panics: assertion left == right failed.
kani autoharness -Z autoharness repro.rs --harness nomatch panics the same way.

The compiler's filtered list includes the automatic harness for add, but the debug-build re-check (find_proof_harnesses) skips automatic harnesses, so the two lists can't match.

@feliperodri

Copy link
Copy Markdown
Member

@tautschnig updated all. ps found checking the zero match path, not sure if known issue. made no sense to fix it as part of this pr, but if needed can do a separate pr if needed... on a debug build, any --harness filter under autoharness panics in determine_targets (kani-driver/src/metadata.rs:108), when at least one automatic harness is generated:

fn add(a: u8, b: u8) -> u8 {
    a.wrapping_add(b)
}

#[kani::proof]
fn manual() {
    assert!(add(1, 1) == 2);
}

kani autoharness -Z autoharness repro.rs verifies both and exits 0. kani autoharness -Z autoharness repro.rs --harness manual panics: assertion left == right failed. kani autoharness -Z autoharness repro.rs --harness nomatch panics the same way.

The compiler's filtered list includes the automatic harness for add, but the debug-build re-check (find_proof_harnesses) skips automatic harnesses, so the two lists can't match.

@ivmat nice, this isn't known! I reproduced it on main: the compiler adds automatic harnesses after applying --harness to manual ones, and the debug re-check excludes them. Could you open an issue with the reproducer? One thing worth settling there is what --harness should mean under autoharness, since in release builds the zero-match check from #4743 probably doesn't fire when automatic harnesses exist.

@feliperodri
feliperodri added this pull request to the merge queue Sep 30, 2026
Merged via the queue into model-checking:main with commit 9751181 Sep 30, 2026
32 of 33 checks passed
srivatsansamraj pushed a commit to srivatsansamraj/kani that referenced this pull request Sep 30, 2026
…del-checking#4923)

Pass `--harness-timeout 5m` to
`script-based-pre/cargo_autoharness_fmt_impls`, as the other autoharness
tests (`bounded`, `bounds`, `byte_str`, `c_str`, `formatter`, `wtf8`)
already do.

**Why.** On the macOS x86_64 runners (`regression (macos-15-intel)`),
the `LowerExp`, `UpperExp` and `Pointer` harnesses of this test take
40–60 s, right at `kani autoharness`'s default `--harness-timeout` of 60
s. When one of them times out, CBMC reports `CBMC timed out` instead of
the expected failure, the test's `Failed Checks: "lower exp"` / `"upper
exp"` / `"pointer"` line is missing, and the test fails. The same
harnesses take about 10 s on Linux.

**Evidence.** I went through the logs of the `regression
(macos-15-intel)` jobs between 2026-09-28 and 2026-09-30. 33 of them
failed. This test failed in all 33, with 1–3 of those three harnesses
timing out each time, and in 32 of them it was the only failing test.
The one exception, model-checking#4903's merge-queue push run, also had
`cargo_autoharness_wtf8`'s `len` harness time out, at 5 m. On main
pushes alone, the job failed 7 times out of 12 on 2026-09-30. The
failures are independent of the changes under test:

- Today's automated toolchain upgrade, model-checking#4917: [run
36663872235](https://github.com/model-checking/kani/actions/runs/36663872235/job/109726991201)
(`LowExp`, `UpExp`, `Ptr` timed out; every other regression job passed)
- `main` pushes:
[36654469481](https://github.com/model-checking/kani/actions/runs/36654469481/job/109695682794),
[36656240395](https://github.com/model-checking/kani/actions/runs/36656240395/job/109701095388),
[36657849257](https://github.com/model-checking/kani/actions/runs/36657849257/job/109705923680),
[36659060566](https://github.com/model-checking/kani/actions/runs/36659060566/job/109709545862),
[36670355214](https://github.com/model-checking/kani/actions/runs/36670355214/job/109743820142),
[36674524840](https://github.com/model-checking/kani/actions/runs/36674524840/job/109756493668)
- Merge queue: model-checking#4895
[36650793954](https://github.com/model-checking/kani/actions/runs/36650793954/job/109684194253),
model-checking#4896
[36650908721](https://github.com/model-checking/kani/actions/runs/36650908721/job/109684568489),
model-checking#4809
[36654883143](https://github.com/model-checking/kani/actions/runs/36654883143/job/109696960300),
model-checking#4848
[36663305755](https://github.com/model-checking/kani/actions/runs/36663305755/job/109722546228),
model-checking#4903
[36667236036](https://github.com/model-checking/kani/actions/runs/36667236036/job/109734401431),
model-checking#4856
[36670723600](https://github.com/model-checking/kani/actions/runs/36670723600/job/109744937944),
model-checking#4881
[36596324505](https://github.com/model-checking/kani/actions/runs/36596324505/job/109502054372),
model-checking#4882
[36612997613](https://github.com/model-checking/kani/actions/runs/36612997613/job/109558873539)
- Pull requests: model-checking#4875
[36427316996](https://github.com/model-checking/kani/actions/runs/36427316996/job/109072277288),
model-checking#4895
[36443349794](https://github.com/model-checking/kani/actions/runs/36443349794/job/108999214513),
model-checking#4771
[36620184925](https://github.com/model-checking/kani/actions/runs/36620184925/job/109677883533)

The runner image version (`20260819.586`) was the same in passing and
failing runs.

**Manual testing.** Locally the three harnesses take about 10 s each.
Running the test with `--harness-timeout 3s` reproduces the CI failure
exactly: the same three harnesses time out, their `Failed Checks` lines
are missing, and the summary still reports 9 failures. With this change,
`cargo run -p compiletest -- --suite script-based-pre --mode exec
cargo_autoharness_fmt_impls` passes.

If the macOS Intel runner gets much slower, a longer timeout alone may
not be enough; making these three harnesses cheaper would be the next
step.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

Co-authored-by: Kiro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

not sure if issue, more a question, is this expected or not: --quiet makes a failing verification run exit 0

4 participants