()
| 53 | |
| 54 | |
| 55 | def main() -> int: |
| 56 | parser = argparse.ArgumentParser() |
| 57 | parser.add_argument("paths", nargs="*", default=["Article"]) |
| 58 | parser.add_argument("--timeout", type=int, default=10) |
| 59 | args = parser.parse_args() |
| 60 | |
| 61 | failed = 0 |
| 62 | total = 0 |
| 63 | skipped = 0 |
| 64 | |
| 65 | for top in args.paths: |
| 66 | root = Path(top) |
| 67 | if not root.exists(): |
| 68 | print(f"路径不存在:{root}", file=sys.stderr) |
| 69 | continue |
| 70 | for md in sorted(root.rglob("*.md")): |
| 71 | for line_no, code, skip in extract_blocks(md): |
| 72 | total += 1 |
| 73 | if skip: |
| 74 | skipped += 1 |
| 75 | continue |
| 76 | ok, err = run_block(code, args.timeout) |
| 77 | if not ok: |
| 78 | failed += 1 |
| 79 | print(f"FAIL {md}:{line_no}\n {err.strip()}\n") |
| 80 | |
| 81 | print(f"\n总计 {total} 块;跳过 {skipped};失败 {failed}") |
| 82 | return 1 if failed > 0 else 0 |
| 83 | |
| 84 | |
| 85 | if __name__ == "__main__": |
no test coverage detected