Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.
Rust agent-skillsclaude-codeclicode-migrationcodexffigolangjavajavascriptmcpmigrationnapiperformanceportingpyo3pythonrewriterubyrusttypescript
fuzz: say how many mismatches it left out of the list (#1272)
jakalijeyd751fe3563d2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8db6acb1..16d4a4e0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,6 +2,8 @@## Unreleased+- `fuzz` ends its list of mismatches with `- ... and N more` when more cases failed than it shows,+ as `app replay` does. Before, the first 20 read as all of them (#1261 by @jakalijey).- Go: a `range` is a hash iteration order risk only over a map literal, a `maps.` call or a namedeclared as a map. Before, any operand with `map` in its text counted, so ranging over a slicenamed `bitmap`, `roadmap` or `mapping` was reported as a high-severity risk (#1255 by @jakalijey).diff --git a/src/main.rs b/src/main.rsindex 9a7b5dab..505b1266 100644--- a/src/main.rs+++ b/src/main.rs@@ -1153,6 +1153,35 @@ fn counted(n: usize, word: &str) -> String {}}+/// `fuzz`'s mismatch lines, ending with `- ... and N more` when it failed more cases than it kept,+/// as `app replay` does.+fn fuzz_mismatch_lines(f: &rust_anything::fuzz::FuzzOutcome) -> Vec<String> {+ let mut lines: Vec<String> = f+ .mismatches+ .iter()+ .map(|m| {+ format!(+ "- {}({}): expected {}, got {}",+ m["fn"].as_str().unwrap_or_default(),+ m["args"]+ .as_array()+ .map(|a| a+ .iter()+ .map(ToString::to_string)+ .collect::<Vec<_>>()+ .join(", "))+ .unwrap_or_default(),+ m["expected"],+ m["actual"]+ )+ })+ .collect();+ if f.failed > f.mismatches.len() {+ lines.push(format!("- ... and {} more", f.failed - f.mismatches.len()));+ }+ lines+}+/// What `app record` prints when it finishes: every count singular for one, so a one-trap/// recording does not say "1 traps".#[allow(clippy::too_many_arguments)]@@ -1845,21 +1874,8 @@ fn run() -> Result<ExitCode> {if !f.missing.is_empty() {say!("Missing exports: {}", f.missing.join(", "));}- for m in &f.mismatches {- say!(- "- {}({}): expected {}, got {}",- m["fn"].as_str().unwrap_or_default(),- m["args"]- .as_array()- .map(|a| a- .iter()- .map(ToString::to_string)- .collect::<Vec<_>>()- .join(", "))- .unwrap_or_default(),- m["expected"],- m["actual"]- );+ for line in fuzz_mismatch_lines(&f) {+ say!("{line}");}if f.kept > 0 {let case_noun = if f.kept == 1 { "case" } else { "cases" };@@ -3076,7 +3092,8 @@ fn rules_empty_hint(root: &std::path::Path, file: &std::path::Path) -> String {#[cfg(test)]mod tests {use super::{- bench_summary_lines, diff_group_lines, group_lines, recorded_summary, rules_empty_hint,+ bench_summary_lines, diff_group_lines, fuzz_mismatch_lines, group_lines, recorded_summary,+ rules_empty_hint,};use rust_anything::harness::{BenchRow, DiffOutcome, verdict};use rust_anything::lang::Lang;@@ -3107,6 +3124,33 @@ mod tests {}}+ #[test]+ fn fuzz_says_how_many_mismatches_it_left_out() {+ let outcome = |shown: usize, failed: usize| {+ rust_anything::fuzz::FuzzOutcome {+ seed: 7,+ rounds: 1,+ cases: 79,+ passed: 79 - failed,+ failed,+ missing: Vec::new(),+ mismatches: (0..shown)+ .map(|i| json!({"fn": "add", "args": [i, 1], "expected": {"ok": i + 1}, "actual": {"ok": i + 2}}))+ .collect(),+ kept: 0,+ recording: Path::new("cases.jsonl").to_path_buf(),+ dropped: 0,+ }+ };+ let lines = fuzz_mismatch_lines(&outcome(20, 49));+ assert_eq!(lines.len(), 21);+ assert_eq!(lines[0], r#"- add(0, 1): expected {"ok":1}, got {"ok":2}"#);+ assert_eq!(lines.last().unwrap(), "- ... and 29 more");+ let lines = fuzz_mismatch_lines(&outcome(3, 3));+ assert_eq!(lines.len(), 3);+ assert!(lines.iter().all(|l| !l.contains("more")), "{lines:?}");+ }+#[test]fn bench_summary_omits_overall_when_nothing_is_compared() {let all_failing = vec![