This repository has been archived on 2025-11-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
lilunar/batch_run.py

45 lines
1.2 KiB
Python
Raw Permalink Normal View History

import os
import asyncio
2025-11-20 17:06:45 +08:00
async def check_file(in_path, out_path, knf_path):
proc = await asyncio.create_subprocess_exec(
"moon",
"run",
"src/bin/main.mbt",
"--",
2025-11-05 22:12:40 +08:00
in_path,
"-o",
out_path,
2025-11-20 17:06:45 +08:00
"--knf-output",
knf_path,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await proc.communicate()
if proc.returncode != 0:
print(f"""
2025-11-05 22:12:40 +08:00
[{proc.returncode}] Error in file {in_path}:
======== STDOUT ========
{stdout.decode()}
======== STDERR ========
{stderr.decode()}
""")
else:
2025-11-05 22:12:40 +08:00
print(f"File {in_path} compiled successfully.")
async def main():
tasks = []
for file in os.listdir("contest-2025-data/test_cases/mbt"):
if file.endswith(".mbt"):
2025-11-05 22:12:40 +08:00
in_path = os.path.join("contest-2025-data/test_cases/mbt", file)
2025-11-11 05:28:39 +08:00
out_path = os.path.join("output/repo", file.replace(".mbt", ".ll"))
2025-11-20 17:06:45 +08:00
knf_path = os.path.join("output/repo", file.replace(".mbt", ".txt"))
tasks.append(check_file(in_path, out_path, knf_path))
await asyncio.gather(*tasks)
if __name__ == "__main__":
asyncio.run(main())