feat: 多轮运行 + GCOV 合并 + JSON 出力 + DesignDataGenerator
This commit is contained in:
@@ -271,6 +271,26 @@ def _chain_prev(records, path_infos, fields, fd_fields, field_to_fd, open_dir):
|
||||
prev_src = k
|
||||
|
||||
|
||||
def _inject_empty_emp_rec(records, fields):
|
||||
"""Insert a record with empty EMP-ID to trigger SPACE comparison paths."""
|
||||
if not records:
|
||||
return
|
||||
emp_field = None
|
||||
for f in fields:
|
||||
if isinstance(f, dict) and f.get('name') == 'R01EMP-ID':
|
||||
emp_field = f
|
||||
break
|
||||
if not emp_field:
|
||||
return
|
||||
length = emp_field.get('pic_info', {}).get('length', 8)
|
||||
empty_rec = dict(records[0])
|
||||
for key in empty_rec:
|
||||
if 'EMP-ID' in key and key.startswith('R01'):
|
||||
empty_rec[key] = ' ' * length
|
||||
records.insert(0, empty_rec)
|
||||
logger.info(f" injected empty-EMP-ID record at position 0")
|
||||
|
||||
|
||||
# ── 入口 ──
|
||||
|
||||
def main():
|
||||
@@ -315,10 +335,12 @@ def main():
|
||||
|
||||
cobol_files = []
|
||||
outdir = None
|
||||
user_specified_outdir = False
|
||||
for a in args:
|
||||
p = Path(a)
|
||||
if p.is_dir() or (not p.suffix and p.parent.exists()):
|
||||
outdir = p
|
||||
user_specified_outdir = True
|
||||
elif p.suffix.upper() in ('.CBL', '.COB', '.CPY'):
|
||||
cobol_files.append(p)
|
||||
else:
|
||||
@@ -327,7 +349,10 @@ def main():
|
||||
print("错误:未找到任何 COBOL 文件")
|
||||
sys.exit(1)
|
||||
if outdir is None:
|
||||
outdir = cobol_files[0].parent
|
||||
from pathlib import Path as _Path
|
||||
_v3_root = _Path(__file__).parent.parent
|
||||
outdir = _v3_root / "runtime"
|
||||
user_specified_outdir = False
|
||||
|
||||
outdir.mkdir(parents=True, exist_ok=True)
|
||||
(outdir / 'logs').mkdir(parents=True, exist_ok=True)
|
||||
@@ -606,6 +631,9 @@ def main():
|
||||
logger.info(f" 检测到多 WRITE FD: {', '.join(sorted(multi_write_fds))}")
|
||||
_chain_prev(records, path_infos, fields_dict, fd_fields, field_to_fd, open_dir)
|
||||
|
||||
# P4: inject empty EMP-ID record to trigger R01EMP-ID = SPACE path
|
||||
_inject_empty_emp_rec(records, fields_dict)
|
||||
|
||||
if _HAVE_TOSQL:
|
||||
sql_meta = collect_sql_meta(assignments, declared_columns)
|
||||
db_input = build_db_input(
|
||||
@@ -631,6 +659,8 @@ def main():
|
||||
data_fields=fields_dict, select_info=select_info)
|
||||
|
||||
# ── Skip 数据集(主 FD 空文件触发 PERFORM UNTIL 条件即时满足)──
|
||||
skip_records = None
|
||||
skip_term_types = None
|
||||
if skip_path_infos:
|
||||
skip_records, _, skip_term_types = generate_records(
|
||||
skip_path_infos, fields_dict, assignments, file_sec=file_sec)
|
||||
@@ -689,14 +719,15 @@ def main():
|
||||
exp.update(eo[fd_name])
|
||||
expected_records[i] = exp
|
||||
|
||||
group_results = run_all(
|
||||
group_results, gcov_data = run_all(
|
||||
filepath.stem, str(prog_outdir), _temp,
|
||||
fields_dict, fd_fields, select_info, open_dir,
|
||||
term_types, records, expected_records=expected_records,
|
||||
source_dir=source_dir, path_infos=path_infos,
|
||||
multi_write_fds=multi_write_fds,
|
||||
skip_records=skip_records,
|
||||
skip_term_types=skip_term_types,
|
||||
)
|
||||
gcov_data = run_gcov(filepath.stem, _temp)
|
||||
|
||||
passed = sum(1 for r in group_results if r.passed)
|
||||
total = len(group_results)
|
||||
|
||||
Reference in New Issue
Block a user