import os
import asyncio
async def check_file(in_path, out_path):
proc = await asyncio.create_subprocess_exec(
"moon",
"run",
"src/bin/main.mbt",
"--",
in_path,
"-o",
out_path,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await proc.communicate()
if proc.returncode != 0:
print(f"""
[{proc.returncode}] Error in file {in_path}:
======== STDOUT ========
{stdout.decode()}
======== STDERR ========
{stderr.decode()}
""")
else:
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"):
in_path = os.path.join("contest-2025-data/test_cases/mbt", file)
out_path = os.path.join("output/repo", file.replace(".mbt", ".ll"))
tasks.append(check_file(in_path, out_path))
await asyncio.gather(*tasks)
if __name__ == "__main__":
asyncio.run(main())