codewalk 0.3.0

Walk code trees with binary detection, bounded reads, and scanner-oriented filtering
Documentation
//! WAVE2 — codewalk / walkkit facade invariants.
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]

use proptest::prelude::*;

macro_rules! wave2_codewalk {
    ($($name:ident => |$bind:ident| $body:block),+ $(,)?) => {
        $(proptest! {
            #![proptest_config(ProptestConfig::with_cases(32))]
            #[test]
            fn $name($bind in prop::collection::vec(any::<u8>(), 0..256)) {
                $body
            }
        })+
    };
}

wave2_codewalk! {
    p00_from_toml_no_panic => |p| { let s = String::from_utf8_lossy(&p); let _ = codewalk::WalkConfig::from_toml(&s); },
    p01_filecontent_text_utf8 => |p| { if let Ok(text) = String::from_utf8(p.clone()) { let fc = codewalk::FileContent::Text(text.clone()); prop_assert!(fc.is_text()); prop_assert_eq!(fc.as_bytes(), text.as_bytes()); } },
    p02_filecontent_unknown_non_utf8 => |p| { if String::from_utf8(p.clone()).is_err() { let fc = codewalk::FileContent::Unknown(p.clone()); prop_assert!(fc.is_unknown()); prop_assert!(fc.as_text().is_none()); } },
    p03_filecontent_binary_flag => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert!(fc.is_binary()); prop_assert!(!fc.is_text()); },
    p04_is_binary_no_panic_on_disk => |p| { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("f.bin"); std::fs::write(&path, &p).unwrap(); let _ = codewalk::detect::is_binary(&path); },
    p05_walkconfig_default_max_file_size_positive => |p| { let cfg = codewalk::WalkConfig::default(); prop_assert!(cfg.max_file_size > 0); },
    p06_walkconfig_builder_chain => |p| { let cfg = codewalk::WalkConfig::builder().max_file_size(p.len() as u64); prop_assert_eq!(cfg.max_file_size, p.len() as u64); },
    p07_artifact_defaults_no_exclude_dirs => |p| { let cfg = codewalk::WalkConfig::artifact_defaults(); prop_assert!(cfg.exclude_dirs.is_empty()); },
    p08_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p09_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p10_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p11_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p12_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p13_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p14_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p15_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p16_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p17_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p18_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p19_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p20_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p21_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p22_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p23_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p24_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p25_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p26_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p27_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p28_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p29_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p30_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p31_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p32_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p33_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p34_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p35_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p36_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p37_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p38_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p39_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p40_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p41_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p42_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
    p43_filecontent_as_bytes_length => |p| { let fc = codewalk::FileContent::Binary(p.clone()); prop_assert_eq!(fc.as_bytes().len(), p.len()); },
}