Files
cobol-java-v3/runners/cobol_runner.py
T
hangshuo652 bc1d56d1a4 feat: Phase 2 complete — 13 Phases of COBOL type classification and test benchmark
P0.6: gcov infrastructure
P1: extract_structure output expansion (11 new feature fields)
P2: Confusion group rule engine (8 pairs + contradiction + backtrack)
P3: 4-factor confidence calculation + quality gate update
P4: 33+2 COBOL program type test samples (22 files, 7 categories)
P5: parametrized/ test data generation engine
P6: japanese_data.py lookup tables
P7-10: Type-specific test suites (~159 parametrized tests)
P11: Full classification pipeline (classify_program) + orchestrator integration
P12: Documentation (module-interfaces, test-plan v3.0, coverage-matrix)

Architecture decisions:
- classification_pipeline/ merged to hina/pipeline/
- parametrized/ as independent module
- japanese_data.py as root-level file
- hina/__all__ only exports classify_program()

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-19 23:51:55 +08:00

22 lines
954 B
Python

import subprocess
from pathlib import Path
from runners.runner import BuildResult, RunResult
class CobolRunner:
def compile(self, src: str, dialect="ibm", gcov: bool = False) -> BuildResult:
stem = Path(src).stem
out = str(Path(src).parent / stem)
cmd = ["cobc", "-x", f"-std={dialect}-strict", "-o", out, src]
if gcov:
cmd = ["cobc", "-x", f"-std={dialect}-strict", "--coverage", "-o", out, src]
p = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
return BuildResult(success=p.returncode == 0, artifact_path=out, log=p.stdout + p.stderr)
def run(self, binary: str, input_path: str, output_path: str) -> RunResult:
with open(input_path, "rb") as f:
data = f.read()
p = subprocess.run([binary], input=data, capture_output=True, timeout=30)
Path(output_path).write_bytes(p.stdout)
return RunResult(success=p.returncode == 0)