BurntSushi/ripgrep
Testing is two-tier and unusually thorough for a CLI. Integration tests live in `tests/` behind a single `[[test]] integration` target and drive the real `rg` binary in a temp directory via a `Dir`/`TestCommand` harness; the `rgtest!` macro automatically runs every test twice — once with the default engine and once with PCRE2 — when the `pcre2` feature is on. Unit tests live inline in `#[cfg(test)] mod tests` blocks, heavily concentrated in `crates/core/flags/defs.rs` (116 `#[test]`s, mostly per-flag parse assertions) and `crates/printer/src/standard.rs` (74). CI runs the suite on 18 build configurations including cross-compiled big-endian (s390x, powerpc64) and 32-bit targets, plus rustfmt, `cargo doc` with `-D warnings`, a wasm32-wasip1 build check, and a cargo-fuzz compile check. There is no coverage measurement and no benchmark job; `benchsuite/` is a separate Python/shell harness not run by CI.
- The integration suite is one binary: `tests/tests.rs` declares modules `binary`, `feature`, `json`, `misc`, `multiline`, `regression`, plus `index` gated on `#[cfg(feature = "unstable-index")]`.
- Test volume by area: `regression.rs` has 110 `rgtest!` cases, `misc.rs` 95, `feature.rs` 82, `binary.rs` 29, `json.rs` 9, `multiline.rs` 8 — regression tests are the single largest group.
- `rgtest!` runs each test body twice when built with the `pcre2` feature — once via `util::setup` and once via `util::setup_pcre2` — which is why CI skips PCRE2 tests under cross/qemu to avoid doubling runtime.
- `Dir::new` locates the `rg` binary relative to `env::current_exe()` and creates an isolated temp working directory keyed by a global atomic counter, so tests can create real files and symlinks.
- `TestCommand::env` exists specifically so tests can exercise environment-driven behavior such as `RIPGREP_CONFIG_PATH`.
- Decompression is covered by committed fixture files: `tests/data/` contains `sherlock.{gz,bz2,xz,lz4,lzma,br,zst,Z}` matching the glob table in `default_decompression_commands`.
- `cmd_exists` lets tests skip gracefully when an external decompression binary isn't installed on the runner, by probing `program --help`.
- Index tests are split into `tests/index/basic.rs` (UX happy paths) and `tests/index/disallowed.rs`, the latter asserting that `-X` combined with `--files-without-match`, `--text` or `-Eutf16` errors out.
- `crates/core/flags/defs.rs` carries 116 `#[test]` functions — largely `parse_low_raw([...])` assertions per flag — making the flag table the most densely unit-tested file in the repo.
- Structural invariants of the flag table are enforced by tests: `shorts_no_duplicates`, `longs_no_duplicates`, `shorts_all_ascii_alphanumeric` and `longs_all_ascii_alphanumeric` (which also validates aliases and negations).
- CI runs two informational tests with `--nocapture`: `flags::defs::tests::available_shorts` (prints unused short-flag letters) and grep-cli's `print_hostname`.
- Shell completion correctness is tested outside cargo by the `ci/test-complete` script, which is skipped on Windows and on cross-compiled targets.
- The CI matrix pins the MSRV build to Rust 1.96.0 and includes big-endian (s390x, powerpc64), 32-bit (i686, armv7) and Windows-on-ARM runners, so endianness and pointer-width bugs are caught.
- Fuzzing is compile-checked only: the `fuzz_testing` CI job installs `cargo-fuzz` and runs `cargo check` in `fuzz/`; the sole target is `fuzz_glob` against the `globset` crate's `arbitrary` feature — the searcher and printer are not fuzzed.
- Documentation is gated in CI: `cargo doc --no-deps --document-private-items --workspace` runs with `RUSTDOCFLAGS: -D warnings`, so a broken intra-doc link fails the build.