1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! M14 #119 — bench harness compile + `--quick` smoke gate.
//!
//! The full `cargo bench --bench perf_table` run takes ~30 minutes
//! on macOS Apple Silicon (10 minutes on Linux x86-64 `NVMe`). The
//! per-PR CI matrix can't afford that latency. This test validates
//! the harness *shape* by running `cargo bench --bench perf_table --
//! --quick`, which exercises a single criterion sample per row in
//! under five minutes total.
//!
//! The test is marked `#[ignore]` so `cargo test` skips it by
//! default — it still builds (catching API drift) and a developer
//! can opt in with `cargo test --release -- --ignored
//! perf_table_compiles`.
//!
//! The test asserts:
//! 1. The bench compiles and runs to completion (exit 0).
//! 2. The markdown table lands at the expected path or the
//! stdout transcript contains the header line.
//!
//! Power-of-ten posture:
//! - Rule 2: no manual loops here — `Command::output` is a single
//! syscall sequence.
//! - Rule 7: every `Result` propagated with `.expect` + diagnostic.
#![forbid(unsafe_code)]
use std::process::Command;
#[test]
#[ignore = "runs the perf_table bench; ~5 minutes on Apple Silicon"]
fn perf_table_quick_runs() {
let output = Command::new(env!("CARGO"))
.args(["bench", "--bench", "perf_table", "--", "--quick"])
.output()
.expect("invoke cargo bench");
let stdout = String::from_utf8_lossy(&output.stdout);
let stderr = String::from_utf8_lossy(&output.stderr);
assert!(
output.status.success(),
"perf_table bench failed: status = {:?}\nstdout:\n{stdout}\nstderr:\n{stderr}",
output.status,
);
// The bench prints the markdown table header to stdout. If
// the header is missing the harness regressed; the bench
// either crashed or its emit path was bypassed.
assert!(
stdout.contains("# obj perf table (M14 #119)"),
"expected markdown header in stdout:\n{stdout}",
);
assert!(
stdout.contains("| Operation | Measured (median) | Target (design.md) | Notes |"),
"expected markdown table header in stdout:\n{stdout}",
);
}