void onyx_wasm_module_write_to_file(OnyxWasmModule* module, bh_file file);
#ifdef ENABLE_RUN_WITH_WASMER
-void onyx_run_wasm(bh_buffer code_buffer);
+b32 onyx_run_wasm(bh_buffer code_buffer);
#endif
#endif
return;
}
+at_least_one_test_failed := false;
+
test_cases :: (cases) => {
for #no_close *cases {
printf("[{}] Running test {}...\n", context.thread_id, it.source_file);
if exit := io.process_wait(^proc); exit != .Success {
// Error running the test case
print_color(.Red, "[{}] Error compiling test case {}.\n{}", context.thread_id, it.source_file, output);
+ at_least_one_test_failed = true;
continue;
}
if output != expected_output {
print_color(.Red, "[{}] Output did not match for {}.\n", context.thread_id, it.source_file);
+ at_least_one_test_failed = true;
}
}
}
case_iterator->close();
- println("Done");
+ if at_least_one_test_failed {
+ print_color(.Red, "FAILED\n");
+ (package wasi).proc_exit(1);
+
+ } else {
+ print_color(.Green, "SUCCESS\n");
+ }
}
\ No newline at end of file
}
#ifdef ENABLE_RUN_WITH_WASMER
-static void onyx_run() {
+static b32 onyx_run() {
bh_buffer code_buffer;
onyx_wasm_module_write_to_buffer(context.wasm_module, &code_buffer);
if (context.options->verbose_output > 0)
bh_printf("Running program:\n");
- onyx_run_wasm(code_buffer);
+ return onyx_run_wasm(code_buffer);
}
#endif
case ONYX_COMPILE_ACTION_RUN:
compiler_progress = onyx_compile();
if (compiler_progress == ONYX_COMPILER_PROGRESS_SUCCESS) {
- onyx_run();
+ if (!onyx_run()) {
+ compiler_progress = ONYX_COMPILER_PROGRESS_ERROR;
+ }
}
break;
#endif
return NULL;
}
-void onyx_run_wasm(bh_buffer wasm_bytes) {
+// Returns 1 if successful
+b32 onyx_run_wasm(bh_buffer wasm_bytes) {
wasm_instance_t* instance = NULL;
wasmer_features_t* features = NULL;
+ wasm_trap_t* run_trap = NULL;
wasm_config = wasm_config_new();
if (!wasm_config) goto error_handling;
bad_import:
bh_printf("Couldn't find import %b.%b.\n", module_name->data, module_name->size, import_name->data, import_name->size);
- return;
+ return 0;
}
wasm_trap_t* traps = NULL;
wasm_val_vec_t results;
wasm_val_vec_new_uninitialized(&args, 0);
- wasm_func_call(start_func, &args, &results);
+ run_trap = wasm_func_call(start_func, &args, &results);
goto cleanup;
if (wasm_module) wasm_module_delete(wasm_module);
if (wasm_store) wasm_store_delete(wasm_store);
if (wasm_engine) wasm_engine_delete(wasm_engine);
- return;
+ return run_trap == NULL;
}