()
| 223 | |
| 224 | |
| 225 | def main() -> None: |
| 226 | parser = ArgumentParser( |
| 227 | description="Show BOLT text not covered by any source code comment" |
| 228 | ) |
| 229 | parser.add_argument( |
| 230 | "--boltdir", default="../lightning-rfc", |
| 231 | help="Directory containing BOLT spec files (default: ../lightning-rfc)" |
| 232 | ) |
| 233 | parser.add_argument( |
| 234 | "--coverage", required=True, metavar="FILE", |
| 235 | help="Coverage file produced by check_quotes.py --coverage=FILE" |
| 236 | ) |
| 237 | parser.add_argument( |
| 238 | "--bolt", type=int, action="append", dest="bolts", metavar="N", |
| 239 | help="Restrict to BOLT #N (may be repeated; default: all bolts in coverage file)" |
| 240 | ) |
| 241 | parser.add_argument( |
| 242 | "--all-sections", action="store_true", |
| 243 | help="Check all sections, not just Requirements sections" |
| 244 | ) |
| 245 | args = parser.parse_args() |
| 246 | |
| 247 | coverage = load_coverage(args.coverage) |
| 248 | bolts_to_check = sorted(args.bolts if args.bolts else coverage.keys()) |
| 249 | |
| 250 | any_uncovered = False |
| 251 | for bolt_num in bolts_to_check: |
| 252 | try: |
| 253 | boltpath, sections = load_bolt(args.boltdir, bolt_num) |
| 254 | except SystemExit: |
| 255 | continue |
| 256 | |
| 257 | # Group records by section index. |
| 258 | by_section: Dict[int, List[CovRecord]] = defaultdict(list) |
| 259 | for rec in coverage.get(bolt_num, []): |
| 260 | si = rec[0] |
| 261 | if 0 <= si < len(sections): |
| 262 | by_section[si].append(rec) |
| 263 | |
| 264 | for si, (text, linemap) in enumerate(sections): |
| 265 | if not text.strip(): |
| 266 | continue |
| 267 | if not args.all_sections and not is_requirements_section(text): |
| 268 | continue |
| 269 | |
| 270 | records = by_section.get(si, []) |
| 271 | if show_gaps(boltpath, bolt_num, si, text, linemap, records): |
| 272 | any_uncovered = True |
| 273 | |
| 274 | sys.exit(1 if any_uncovered else 0) |
| 275 | |
| 276 | |
| 277 | if __name__ == "__main__": |
no test coverage detected