diff --git a/run.py b/run.py index 101ed3f..90496d6 100644 --- a/run.py +++ b/run.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -"""COBOL 迁移验证平台全流程入口:先白盒 cobol_testgen 再黑盒 LLM 数据生成。 +"""COBOL 迁移验证平台全流程入口:先黑盒 LLM 数据生成,再白盒+黑盒运行比对。 用法: python run.py --design <詳細設計書.md> --source <程序.cbl> \ @@ -7,8 +7,8 @@ --db-md --output <输出目录> 步骤: - 1) cobol_testgen (白盒静态分析 + 测试数据生成) → python -m cobol_testgen --gcov - 2) black-box-data-create (DeepSeek LLM 数据生成) → 透传全部参数给 black-box-data-create/main.py + 1) black-box-data-create (DeepSeek LLM 数据生成) → 透传全部参数给 black-box-data-create/main.py + 2) cobol_testgen (白盒静态分析 + 黑盒数据比对) → python -m cobol_testgen --gcov --black-box / 任一步失败即停止,返回该步退出码。 """ @@ -23,7 +23,7 @@ BLACKBOX_MAIN = os.path.join(ROOT, "black-box-data-create", "main.py") def build_parser(): p = argparse.ArgumentParser( - description="COBOL 迁移验证平台:先跑白盒 cobol_testgen,再跑黑盒 LLM 数据生成") + description="COBOL 迁移验证平台:先跑黑盒 LLM 数据生成,再跑白盒+黑盒 cobol_testgen") p.add_argument("--design", required=True, help="詳細設計書 .md のパス") p.add_argument("--source", required=True, help="COBOL ソース .cbl のパス") p.add_argument("--file-db-md", required=True, help="ファイル/DB 構造 .md のパス") @@ -34,6 +34,8 @@ def build_parser(): p.add_argument("--model", help="API モデル名(透传给黑盒)") p.add_argument("--rules", help="ルール格納ディレクトリ(透传给黑盒)") p.add_argument("--max-tokens", type=int, help="API 生成トークン上限(透传给黑盒)") + p.add_argument("--no-black-box", action="store_true", + help="跳过黑盒数据生成,仅跑白盒 cobol_testgen") p.add_argument("--dry-run", action="store_true", help="只打印要执行的命令,不真正执行") return p @@ -50,34 +52,42 @@ def _run(cmd, cwd, label, dry_run=False): def main(): args = build_parser().parse_args() + program_id = os.path.splitext(os.path.basename(args.source))[0] + program_dir = os.path.join(args.output, program_id) - rc = _run( - [sys.executable, "-m", "cobol_testgen", "--gcov", args.source, args.output], - cwd=ROOT, - label="步骤1: cobol_testgen 白盒数据生成", - dry_run=args.dry_run, - ) - if rc != 0: - return rc + if not args.no_black_box: + bb_cmd = [ + sys.executable, BLACKBOX_MAIN, + "--design", args.design, + "--source", args.source, + "--file-db-md", args.file_db_md, + "--cpy", args.cpy, + "--db-md", args.db_md, + "--output", args.output, + ] + for opt in ("--api-key", "--model", "--rules", "--max-tokens"): + v = getattr(args, opt.lstrip("-").replace("-", "_")) + if v is not None: + bb_cmd.extend([opt, str(v)]) - bb_cmd = [ - sys.executable, BLACKBOX_MAIN, - "--design", args.design, - "--source", args.source, - "--file-db-md", args.file_db_md, - "--cpy", args.cpy, - "--db-md", args.db_md, - "--output", args.output, - ] - for opt in ("--api-key", "--model", "--rules", "--max-tokens"): - v = getattr(args, opt.lstrip("-").replace("-", "_")) - if v is not None: - bb_cmd.extend([opt, str(v)]) + rc = _run( + bb_cmd, + cwd=ROOT, + label="步骤1: black-box-data-create LLM 数据生成", + dry_run=args.dry_run, + ) + if rc != 0: + return rc + + ct_cmd = [sys.executable, "-m", "cobol_testgen", "--gcov"] + if not args.no_black_box: + ct_cmd += ["--black-box", program_dir] + ct_cmd += [args.source, args.output] return _run( - bb_cmd, + ct_cmd, cwd=ROOT, - label="步骤2: black-box-data-create LLM 数据生成", + label="步骤2: cobol_testgen 白盒+黑盒 运行比对", dry_run=args.dry_run, )