45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
import os
|
|
import asyncio
|
|
|
|
|
|
async def check_file(in_path, out_path, knf_path):
|
|
proc = await asyncio.create_subprocess_exec(
|
|
"moon",
|
|
"run",
|
|
"src/bin/main.mbt",
|
|
"--",
|
|
in_path,
|
|
"-o",
|
|
out_path,
|
|
"--knf-output",
|
|
knf_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"))
|
|
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())
|