feat: 多轮运行 + GCOV 合并 + JSON 出力 + DesignDataGenerator

This commit is contained in:
hangshuo652
2026-07-12 21:04:58 +08:00
parent af37e33b98
commit f3be17e5eb
40 changed files with 4397 additions and 198 deletions
+8 -15
View File
@@ -310,22 +310,13 @@ class GixsqlCobolRunner:
logger.info(f" cobc: {' '.join(cmd)}")
try:
r = subprocess.run(cmd, capture_output=True, timeout=60, env=self._build_env())
r = subprocess.run(cmd, capture_output=True, timeout=60, env=self._build_env(),
cwd=str(exe_dir))
log = (r.stdout.decode("utf-8", "replace") + "\n" +
r.stderr.decode("utf-8", "replace"))
if r.returncode != 0:
return GixsqlBuildResult(False, log=log[:1000])
# After successful compile, copy .gcno from CWD to exe_dir
pp_stem = pp_path.stem # e.g. "KIN02UPD_pp"
exe_stem = exe_path.stem # e.g. "KIN02UPD"
copied = 0
for gcno in Path.cwd().glob("*.gcno"):
# Match .gcno files belonging to this compile (by subprogram name or pp_stem partial match)
dst = exe_dir / gcno.name
dst.write_bytes(gcno.read_bytes())
copied += 1
if copied:
logger.debug(f" gcno copied: {copied} files to {exe_dir}")
# .gcno files are generated in exe_dir (compile CWD). No need to copy.
return GixsqlBuildResult(True, exe_path=str(exe_path), log=log[:500])
except subprocess.TimeoutExpired:
return GixsqlBuildResult(False, log="Compile timeout (60s)")
@@ -334,7 +325,8 @@ class GixsqlCobolRunner:
db_path: str | Path,
input_dir: str | Path | None = None,
timeout: int = 30,
cobol_lib_path: str | Path | None = None) -> GixsqlRunResult:
cobol_lib_path: str | Path | None = None,
env_overrides: dict[str, str] | None = None) -> GixsqlRunResult:
"""Step 3: COBOL DB プログラム実行"""
exe_path = Path(exe_path)
work_dir = Path(work_dir)
@@ -379,6 +371,8 @@ class GixsqlCobolRunner:
env["GIXSQL_DB_PATH"] = str(db_path)
if cobol_lib_path:
env["COB_LIBRARY_PATH"] = str(cobol_lib_path)
if env_overrides:
env.update(env_overrides)
if input_dir:
idir = Path(input_dir)
@@ -386,8 +380,7 @@ class GixsqlCobolRunner:
for f in idir.iterdir():
if f.is_file():
dst = work_dir / f.name
if not dst.exists():
dst.write_bytes(f.read_bytes())
dst.write_bytes(f.read_bytes())
cmd = [str(exe_path)]
logger.info(f" run: {' '.join(cmd)} (cwd={work_dir}, db={db_path})")