mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Merge pull request #2625 from laytan/exit-code-1-on-test-failure
exit with code 1 on `odin test` failure
This commit is contained in:
@@ -1825,26 +1825,29 @@ gb_internal lbProcedure *lb_create_main_procedure(lbModule *m, lbProcedure *star
|
|||||||
TEMPORARY_ALLOCATOR_GUARD();
|
TEMPORARY_ALLOCATOR_GUARD();
|
||||||
auto args = array_make<lbValue>(temporary_allocator(), 1);
|
auto args = array_make<lbValue>(temporary_allocator(), 1);
|
||||||
args[0] = lb_addr_load(p, all_tests_slice);
|
args[0] = lb_addr_load(p, all_tests_slice);
|
||||||
lb_emit_call(p, runner, args);
|
lbValue result = lb_emit_call(p, runner, args);
|
||||||
|
|
||||||
|
lbValue exit_runner = lb_find_package_value(m, str_lit("os"), str_lit("exit"));
|
||||||
|
auto exit_args = array_make<lbValue>(temporary_allocator(), 1);
|
||||||
|
exit_args[0] = lb_emit_select(p, result, lb_const_int(m, t_int, 0), lb_const_int(m, t_int, 1));
|
||||||
|
lb_emit_call(p, exit_runner, exit_args, ProcInlining_none);
|
||||||
} else {
|
} else {
|
||||||
if (m->info->entry_point != nullptr) {
|
if (m->info->entry_point != nullptr) {
|
||||||
lbValue entry_point = lb_find_procedure_value_from_entity(m, m->info->entry_point);
|
lbValue entry_point = lb_find_procedure_value_from_entity(m, m->info->entry_point);
|
||||||
lb_emit_call(p, entry_point, {}, ProcInlining_no_inline);
|
lb_emit_call(p, entry_point, {}, ProcInlining_no_inline);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (call_cleanup) {
|
if (call_cleanup) {
|
||||||
lbValue cleanup_runtime_value = {cleanup_runtime->value, cleanup_runtime->type};
|
lbValue cleanup_runtime_value = {cleanup_runtime->value, cleanup_runtime->type};
|
||||||
lb_emit_call(p, cleanup_runtime_value, {}, ProcInlining_none);
|
lb_emit_call(p, cleanup_runtime_value, {}, ProcInlining_none);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (is_dll_main) {
|
if (is_dll_main) {
|
||||||
LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_i32), 1, false));
|
LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_i32), 1, false));
|
||||||
} else {
|
} else {
|
||||||
LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_i32), 0, false));
|
LLVMBuildRet(p->builder, LLVMConstInt(lb_type(m, t_i32), 0, false));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lb_end_procedure_body(p);
|
lb_end_procedure_body(p);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user