forked from LUC-AI4FM/FormaLLM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest
More file actions
36 lines (29 loc) · 1.21 KB
/
test
File metadata and controls
36 lines (29 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@step
def evaluate_tla(specs: dict) -> dict:
project_root = Path(__file__).resolve().parent.parent
generated_dir = project_root / "outputs" / "generated"
eval_output_dir = project_root / "outputs" / "evaluations"
eval_output_dir.mkdir(parents=True, exist_ok=True)
results = {}
for model_name, tla_code in specs.items():
print(f"\n--- Evaluating {model_name} ---")
# Write the generated spec to file
tla_path = generated_dir / f"{model_name}.generated.tla"
tla_path.write_text(tla_code.strip())
# Run TLC without a config file
result = subprocess.run(
["tlc", "-nowarning", str(tla_path)],
capture_output=True,
text=True
)
# Write logs
log_path = eval_output_dir / f"{model_name}.tlc.log"
log_path.write_text(result.stdout + "\n=== STDERR ===\n" + result.stderr)
# Evaluate result based on TLC output
if "The specification is correct" in result.stdout:
results[model_name] = "PASS"
elif "TLC threw an unexpected exception" in result.stdout:
results[model_name] = "ERROR"
else:
results[model_name] = "FAIL"
return results