Skip to content

Commit a4e4379

Browse files
committed
feat: Add support for -x/--exclude-lines.
1 parent a9f5869 commit a4e4379

File tree

2 files changed

+137
-103
lines changed

2 files changed

+137
-103
lines changed

src/slipcover/__main__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def main():
132132
ap.add_argument('--pretty-print', action='store_true', help="pretty-print JSON output")
133133
ap.add_argument('--out', type=Path, help="specify output file name")
134134
ap.add_argument('--source', help="specify directories to cover")
135+
ap.add_argument('-x', '--exclude-lines', action='append', type=str, help="Regex line patterns to ignore coverage for")
135136
ap.add_argument('--omit', help="specify file(s) to omit")
136137
ap.add_argument('--immediate', action='store_true',
137138
help=(argparse.SUPPRESS if platform.python_implementation() == "PyPy" else "request immediate de-instrumentation"))
@@ -185,10 +186,11 @@ def main():
185186
for o in args.omit.split(','):
186187
file_matcher.addOmit(o)
187188

189+
exclude_lines = set(args.exclude_lines) if args.exclude_lines else None
188190

189191
sci = sc.Slipcover(immediate=args.immediate,
190192
d_miss_threshold=args.threshold, branch=args.branch,
191-
disassemble=args.dis, source=args.source)
193+
disassemble=args.dis, source=args.source, exclude_lines=exclude_lines)
192194

193195

194196
if not args.dont_wrap_pytest:

0 commit comments

Comments
 (0)