55 lines
1.6 KiB
Plaintext
55 lines
1.6 KiB
Plaintext
func run_test[x: str] : void
|
|
build_blacklist := ["examples/euler", "examples/raylib.zr", "examples/chip8.zr", "examples/sqlite_todo.zr"]
|
|
run_blacklist := ["guess_number.zr", "tcp_server.zr", "udp_server.zr"]
|
|
|
|
for i in 0..build_blacklist->size
|
|
if x->equal(build_blacklist->nth(i))
|
|
io.printf("Skipping %s...\n", x)
|
|
return
|
|
|
|
io.printf("Building %s...\n", x)
|
|
|
|
build_start_time := os.time()
|
|
~status, ok := os.run_shell_command("./target/release/zern "->concat(x))
|
|
if !ok || status != 0
|
|
os.exit(1)
|
|
build_end_time := os.time()
|
|
|
|
io.printf("%dms\n", build_end_time - build_start_time)
|
|
|
|
for i in 0..run_blacklist->size
|
|
if x->contains(run_blacklist->nth(i))
|
|
io.printf("Skipping %s...\n", x)
|
|
return
|
|
|
|
io.printf("Running %s...\n", x)
|
|
|
|
run_cmd := "./out"
|
|
if x->equal("examples/curl.zr")
|
|
run_cmd = run_cmd->concat(" http://example.com")
|
|
|
|
run_start_time := os.time()
|
|
~status, ok := os.run_shell_command(run_cmd)
|
|
if !ok || status != 0
|
|
io.println("Test failed.")
|
|
os.exit(1)
|
|
run_end_time := os.time()
|
|
|
|
io.printf("Running %s took %dms\n", x, run_end_time - run_start_time)
|
|
|
|
func run_directory[dir: str] : void
|
|
~files, ok := os.list_directory(dir)
|
|
if !ok
|
|
panic("failed to open test directory")
|
|
for i in 0..files->size
|
|
run_test(dir->concat(files->nth(i)))
|
|
|
|
func main[] : i64
|
|
~status, ok := os.run_shell_command("cargo build --release")
|
|
if !ok || status != 0
|
|
os.exit(1)
|
|
|
|
run_directory("examples/")
|
|
run_directory("examples/euler/")
|
|
io.println("DONE")
|