testing
Skill4 starsChanged 4 months agoMITView on GitHub
Testing patterns for lessence. Covers running tests, writing tests, fuzzing (cargo-fuzz), mutation testing (cargo-mutants), code coverage (cargo-llvm-cov), property-based testing (proptest), ReDoS security tests, flaky test diagnosis, and performance regression detection. Use when: "add tests", "run tests", "test coverage", "mutation testing", "fuzz", "flaky test", "ReDoS", "evil pattern", "scaling test".
- Installs packages
123 other projects use a version of this.
Adopted by
Most recently taken up by
- timmo001/skillstheir own version, first seen Oct 5, 2026
- kortix-ai/sunatheir own version, first seen Oct 5, 2026
- gilsmt/skillstheir own version, first seen Oct 4, 2026
- andeeplus/aplustheir own version, first seen Oct 4, 2026
- JetBrains/intellij-communitytheir own version, first seen Oct 3, 2026
- shinpr/codex-workflowstheir own version, first seen Oct 2, 2026
Used with
Projects with it also use oss-pr, pr-automation and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
CES-LtdSkilloss-pr
Use when creating a pull request, after committing changes, or when user invokes /oss-pr. Covers branch management, quality checks, commit, push, and PR creation.
Also in 3 projects that use this
CES-LtdSkillpr-automation
PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".
Also in 3 projects that use this
ffsshhttiikkSkillcicd
Continuous integration and delivery pipelines
Also in 4 projects that use this
ffsshhttiikkSkillnetworking
Practical application and coding skills for Networking
Also in 3 projects that use this
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 9 projects that use this
Cogni-AI-OUSkilldotfiles
Reference for repository dotfiles, including their purposes, standard configurations, and usage guidelines. You MUST load this skill when configuring, troubleshooting, or understanding repository dotfiles.
Also in 3 projects that use this
- +2 more from CES-Ltd
- +1 more from ffsshhttiikk
Other versions123 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 123
- lobehub/lobehub★ 83ksame name
- iOfficeAI/AionUi★ 33ksame name
- JetBrains/intellij-community★ 21ksame name
- kortix-ai/suna★ 20ksame name
- modelcontextprotocol/inspector★ 11ksame name
- microsoft/fast★ 9.7ksame name
- bytebase/dbhub★ 3.6ksame name
- theopenco/llmgateway★ 1.7ksame name
- BankrBot/skills★ 1.2ksame name
- microsoft/CCF★ 875same name
113 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- lessenceSkill
- pattern-devSkill
- releaseSkill
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 2 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 105 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 35
Never use absolute wall-clock assertions (< 100ms).
- Very specific: line 41
Use env!("CARGO_BIN_EXE_lessence") in integration tests, never ./target/release/lessence.
- Very specific: line 52
Use the make_line / make_group helpers in src/folder.rs to build synthetic PatternGroup values for rollup and folding tests.
- Very specific: line 57
Use env!("CARGO_BIN_EXE_lessence") to find the binary:
- Very specific: line 80
Use 4+ similar lines to verify compression (min-collapse default is 3).
- Distinctive: line 85
Test algorithmic complexity, not absolute speed:
- Distinctive: line 172
If cargo-mutants reports a "missed" mutant on one of those lines, don't try to kill it — add to the exclusion list if a new equivalent is …
“Common” is measured: kept by at least 6 in 10 of the 105 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Testing lessence
Running Tests
cargo test --lib # Unit tests only (fast, <2s)
cargo nextest run --release # Full suite in release mode (CI)
make ci # Full CI pipeline (fmt + clippy + doc + build + test + deny)make ci runs automatically via .githooks/pre-push before every
push — blocks the push on failure. A PostToolUse hook in
.claude/settings.json also auto-runs cargo fmt --all after any
.rs Edit/Write from Claude Code, so fmt drift never accumulates
between commits during a Claude session. These two layers mean
CI rarely fails on lint or fmt unless someone explicitly bypasses
the hooks with --no-verify.
Test Speed Rules
Tests must be fast. Slow tests break mutation testing, annoy developers, and hide behind CI where no one watches them.
- Never use absolute wall-clock assertions (
< 100ms). Use scaling-ratio tests instead — measure at input size N and 4N, assert ratio < 8.0. This tests algorithmic complexity and is immune to CPU contention. - Skip expensive operations in debug builds via
cfg!(debug_assertions). Processing 70k lines through a debug binary takes 50s vs 2s in release. The compression ratio is identical — only speed differs. - Use
env!("CARGO_BIN_EXE_lessence")in integration tests, never./target/release/lessence. The hardcoded path breaks under cargo-mutants and ties tests to a specific build profile. - Timing-sensitive tests run in a nextest serial group (
.config/nextest.toml) withmax-threads = 1to eliminate CPU contention flakes.
Writing Tests
Unit Tests (in src/)
Private functions need tests inside #[cfg(test)] mod tests in the same file.
Use the make_line / make_group helpers in src/folder.rs to build synthetic
PatternGroup values for rollup and folding tests.
Integration Tests (in tests/)
Use env!("CARGO_BIN_EXE_lessence") to find the binary:
let output = Command::new(env!("CARGO_BIN_EXE_lessence"))
.args(["--no-stats", "--threads", "1"])
.stdin(std::fs::File::open("tests/fixtures/sample.log").unwrap())
.output()
.expect("failed to run lessence");Tests use a barrel pattern. tests/ has 5 barrel files
(unit.rs, integration.rs, contract.rs, security.rs,
misc.rs), each of which imports submodules from its same-named
subdirectory via mod foo; declarations. Adding a new test means
dropping a .rs file into the right subdirectory and adding a
mod your_test_name; line to the barrel — not adding a new
[[test]] entry to Cargo.toml. A separate [[test]] entry
creates a separate test binary (one link step per file), which
is exactly the compile-time cost the barrel pattern exists to
avoid. See the comment on the [[test]] blocks in Cargo.toml.
Folding Tests
Use 4+ similar lines to verify compression (min-collapse default is 3).
Assert on the presence of "similar" in output, not specific line counts.
ReDoS / Security Tests (scaling-ratio pattern)
Test algorithmic complexity, not absolute speed:
fn assert_linear_scaling(label: &str, make_input: impl Fn(usize) -> String) {
let small = make_input(1);
let large = make_input(4);
let iters = 2000;
let time_small = measure(&small, iters);
let time_large = measure(&large, iters);
let ratio = time_large.as_nanos() as f64 / time_small.as_nanos().max(1) as f64;
assert!(ratio < 8.0,
"{label}: ratio {ratio:.1}x for 4x input (quadratic would be ~16.0)");
}Linear (O(n)) → ratio ≈ 4.0. Quadratic (ReDoS) → ratio ≈ 16.0. Threshold 8.0 gives 2x headroom for noise.
Synthetic Log Generator
tests/fixtures/log_generator.rs generates deterministic kubelet-style logs
at configurable sizes. Use for constitutional compliance tests instead of
depending on gitignored corpus files:
#[path = "../fixtures/log_generator.rs"]
mod log_generator;
let input = log_generator::generate_log(1000); // 98.5% compressionHeavy Testing (Local Only)
These run outside CI. See make help for all targets.
make fuzz # Fuzz normalizer (nightly, 5 min default)
make fuzz FUZZ_WORKERS=8 # Parallel fuzzing on 8 cores
make fuzz-fold # Fuzz full folding pipeline
make mutants # Mutation testing, unit tests via -C --lib (~40 min)
make mutants-full # Mutation testing, full suite including integration (~hours)
make coverage # HTML code coverage reportFuzzing (cargo-fuzz)
Requires nightly: rustup toolchain install nightly && cargo install cargo-fuzz.
Two fuzz targets in fuzz/fuzz_targets/: fuzz_normalize (pattern detectors)
and fuzz_fold (full pipeline). Corpus persists between runs.
Mutation Testing (cargo-mutants)
make mutants, make mutants-full and make release-check all run
through scripts/mutants.sh, which sizes the run to the machine as it
is now: the memory budget is MemAvailable minus a 16 GiB reserve, set
as MemoryHigh (over it the kernel throttles, it does not kill) with
MemoryMax 2 GiB above; the job count is that budget divided by what
one busy worker took last run (target/gate/mutants-mem, anonymous
peak, plus a quarter; 4 GiB when there is no record), capped at cores
and 8. Overrides, on the make line or in the environment:
MUTANTS_RESERVE_GIB(default16) — memory left for everything elseMUTANTS_MEM_MAX— the budget itself, e.g.20GMUTANTS_JOBS— parallel mutant jobsMUTANTS_TIMEOUT_MULT(default3) — timeout multiplier (NOT an absolute seconds value; cargo-mutants times a baseline test run and usesbaseline × multiplieras the per-mutant timeout)
Interpret results: "missed" means a mutant survived — either no test
covers that code path, or the test doesn't assert tightly enough.
With -C --lib (what make mutants uses), integration-only code
shows as missed — that's expected, use make mutants-full to
include it.
Structurally equivalent mutants — mutations that can't change
observable behavior because of an earlier guard or redundant check
— live in .cargo/mutants.toml under exclude_re. Currently:
network.rs:207— FQDN regex's\banchors already guarantee thecontains('.')/starts_with/ends_withchecksnormalize.rs:59— PathDetector (step 3) replaces&Event{}before JsonDetector (step 4) can see it, so thenormalize_jsonguard is structurally unreachable for that input shapenormalize.rs:173—QuotedStringDetectorhas its ownif !text.contains('"')fast path, making the normalizer's|| contains('\'')branch dead for token emission
If cargo-mutants reports a "missed" mutant on one of those lines, don't try to kill it — add to the exclusion list if a new equivalent is found.
Code Coverage (cargo-llvm-cov)
make coverage # HTML report at target/llvm-cov/html/index.htmlUses --no-fail-fast so timing test failures under instrumentation
don't block the report.
Test Organization
tests/
unit.rs # Barrel — pulls in unit/ submodules
unit/ # Pattern detector unit tests
integration.rs # Barrel — pulls in integration/ submodules
integration/ # CLI and end-to-end tests
contract.rs # Barrel — pulls in contract/ submodules
contract/ # API contract tests
security.rs # Barrel — pulls in security/ submodules
security/ # ReDoS scaling + evil-pattern tests
misc.rs # Barrel — pulls in misc/ submodules
misc/ # Perf/property/snapshot/PII/limits/email tests
common/mod.rs # Shared test helpers (imported by barrels)
fixtures/ # Test data + log_generator.rs
property/ # Proptest regressions (auto-generated; do not commit)
snapshot/snapshots/ # Insta snapshot files (committed, reviewed via `insta review`)
.config/nextest.toml # Serial group + retries for timing tests
.cargo/mutants.toml # Mutants config + exclude_re for equivalentsNextest Configuration
.config/nextest.toml defines a serial-timing test group that runs
timing-sensitive tests with max-threads = 1. Filter pattern:
test(redos) | test(scales_linearly) | test(performance) | test(timeout)
| test(allocation_consistency) | test(backward_compatibility)
| test(unix_timestamp_penalty)This eliminates flakes from CPU contention in parallel test runs.
Tests in that group also retry up to 2 times with exponential backoff (500ms → 5s max). Rationale: noise-induced flakes on a busy machine pass on retry; genuine regressions (e.g. quadratic scaling) fail all three attempts. If a test is intermittently failing but always passing on retry, that's noise — leave it. If it fails all three runs, investigate.
The slow profile (wall-clock tests) is excluded from cargo nextest run
by default-filter; run it with cargo nextest run --release --profile
slow; make release-check does.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

