Expand description
A small rule-test harness (#2842).
Run a rule against an annotated fixture and check that its matches line
up with inline // ruleid: / // ok: comments — the Semgrep convention,
adapted to be language-agnostic:
// ruleid: no-foo
foo(); // <- must match `no-foo`
// ok: no-foo
bar(); // <- must NOT match `no-foo`
baz(); // <- no annotation: must NOT match eitherAn annotation comment sits on its own line and targets the next
line. The check is strict: every match must be covered by a // ruleid:
(an un-annotated match is a false positive), and every // ruleid: line
must match (a missing match is a false negative).
Structs§
- Inline
Test Report - The outcome of running one rule against one annotated fixture.
- Test
Failure - One failed expectation in a fixture.
Enums§
- Expectation
- What an annotation asserts about the line it targets.
- Failure
Kind - Why a fixture line failed its expectation.
Functions§
- run_
inline_ test - Run
ruleagainstsourceand compare its matches with the fixture’s inline// ruleid:/// ok:annotations.