-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun_all_examples.py
More file actions
executable file
·41 lines (34 loc) · 942 Bytes
/
run_all_examples.py
File metadata and controls
executable file
·41 lines (34 loc) · 942 Bytes
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
37
38
39
40
41
#!/usr/bin/env python3
import os
from beancode.runner import *
from argparse import ArgumentParser
def log(s: str):
print(f"\033[33;1m===> {s}\033[0m")
p = ArgumentParser()
p.add_argument(
"-O", "--optimize", action="store_true", help="run the optimizer before execution"
)
args = p.parse_args()
src = ""
for file in sorted(os.listdir("examples")):
if "raylib" in file:
continue
try:
p = os.path.join("examples", file)
if not os.path.isfile(p):
continue
with open(p, "r") as f:
src = f.read()
log(f"running example {file}")
if not execute(
src, filename=file, save_interpreter=True, optimize=args.optimize
):
exit(1)
except KeyboardInterrupt:
log("continuing")
except EOFError:
exit(1)
except Exception as e:
log(f"exception caught:")
print(e.__repr__())
exit(1)