64 lines
1.8 KiB
Plaintext
64 lines
1.8 KiB
Plaintext
func run_test[x: str] : void
|
|
let build_blacklist: Array = ["examples/puzzles", "examples/raylib.zr", "examples/chip8.zr", "examples/sqlite_todo.zr"]
|
|
let run_blacklist: Array = ["/aoc", "guess_number.zr", "tcp_server.zr", "udp_server.zr"]
|
|
|
|
for i in 0..build_blacklist->size
|
|
if str.equal(x, array.nth(build_blacklist, i))
|
|
io.print("Skipping ")
|
|
io.print(x)
|
|
io.println("...")
|
|
return 0
|
|
|
|
io.print("Building ")
|
|
io.print(x)
|
|
io.print("... ")
|
|
|
|
let build_start_time: i64 = os.time()
|
|
if os.run_shell_command(str.concat("./target/release/zern ", x)) != 0
|
|
os.exit(1)
|
|
let build_end_time: i64 = os.time()
|
|
|
|
io.print_i64(build_end_time - build_start_time)
|
|
io.println("ms")
|
|
|
|
for i in 0..run_blacklist->size
|
|
if str.find(x, array.nth(run_blacklist, i)) != -1
|
|
io.print("Skipping ")
|
|
io.print(x)
|
|
io.println("...")
|
|
return 0
|
|
|
|
io.print("Running ")
|
|
io.print(x)
|
|
io.println("...")
|
|
|
|
let run_cmd: str = "./out"
|
|
if str.equal(x, "examples/curl.zr")
|
|
run_cmd = str.concat(run_cmd, " http://example.com")
|
|
else if str.equal(x, "examples/tokenizer.zr")
|
|
run_cmd = str.concat(run_cmd, " test.zr")
|
|
|
|
let run_start_time: i64 = os.time()
|
|
if os.run_shell_command(run_cmd) != 0
|
|
os.exit(1)
|
|
let run_end_time: i64 = os.time()
|
|
|
|
io.print("Running ")
|
|
io.print(x)
|
|
io.print(" took ")
|
|
io.print_i64(run_end_time - run_start_time)
|
|
io.println("ms")
|
|
|
|
func run_directory[dir: str] : void
|
|
let files: Array = os.list_directory(dir)
|
|
for i in 0..files->size
|
|
run_test(str.concat(dir, array.nth(files, i)))
|
|
|
|
array.free(files)
|
|
|
|
func main[] : i64
|
|
os.run_shell_command("cargo build --release")
|
|
|
|
run_directory("examples/")
|
|
run_directory("examples/puzzles/")
|