mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Add pkg field to testing.Internal_Test
This commit is contained in:
@@ -4,6 +4,7 @@ package testing
|
|||||||
import "core:io"
|
import "core:io"
|
||||||
import "core:os"
|
import "core:os"
|
||||||
import "core:strings"
|
import "core:strings"
|
||||||
|
import "core:slice"
|
||||||
|
|
||||||
reset_t :: proc(t: ^T) {
|
reset_t :: proc(t: ^T) {
|
||||||
clear(&t.cleanups);
|
clear(&t.cleanups);
|
||||||
@@ -28,6 +29,15 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
|
|||||||
total_success_count := 0;
|
total_success_count := 0;
|
||||||
total_test_count := len(internal_tests);
|
total_test_count := len(internal_tests);
|
||||||
|
|
||||||
|
slice.sort_by(internal_tests, proc(a, b: Internal_Test) -> bool {
|
||||||
|
if a.pkg < b.pkg {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return a.name < b.name;
|
||||||
|
});
|
||||||
|
|
||||||
|
prev_pkg := "";
|
||||||
|
|
||||||
for it in internal_tests {
|
for it in internal_tests {
|
||||||
if it.p == nil {
|
if it.p == nil {
|
||||||
total_test_count -= 1;
|
total_test_count -= 1;
|
||||||
@@ -40,7 +50,12 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
|
|||||||
|
|
||||||
name := strings.trim_prefix(it.name, "test_");
|
name := strings.trim_prefix(it.name, "test_");
|
||||||
|
|
||||||
logf(t, "[Test: %q]", name);
|
if prev_pkg != it.pkg {
|
||||||
|
prev_pkg = it.pkg;
|
||||||
|
logf(t, "[Package: %s]", it.pkg);
|
||||||
|
}
|
||||||
|
|
||||||
|
logf(t, "[Test: %s]", name);
|
||||||
|
|
||||||
// TODO(bill): Catch panics
|
// TODO(bill): Catch panics
|
||||||
{
|
{
|
||||||
@@ -48,9 +63,9 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if t.error_count != 0 {
|
if t.error_count != 0 {
|
||||||
logf(t, "[%q : FAILURE]", name);
|
logf(t, "[%s : FAILURE]", name);
|
||||||
} else {
|
} else {
|
||||||
logf(t, "[%q : SUCCESS]", name);
|
logf(t, "[%s : SUCCESS]", name);
|
||||||
total_success_count += 1;
|
total_success_count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ package testing
|
|||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "core:io"
|
import "core:io"
|
||||||
|
|
||||||
|
// IMPORTANT NOTE: Compiler requires this layout
|
||||||
Test_Signature :: proc(^T);
|
Test_Signature :: proc(^T);
|
||||||
|
|
||||||
|
// IMPORTANT NOTE: Compiler requires this layout
|
||||||
Internal_Test :: struct {
|
Internal_Test :: struct {
|
||||||
|
pkg: string,
|
||||||
name: string,
|
name: string,
|
||||||
p: Test_Signature,
|
p: Test_Signature,
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -12941,13 +12941,20 @@ void ir_gen_tree(irGen *s) {
|
|||||||
irValue **found = map_get(&m->values, hash_entity(testing_proc));
|
irValue **found = map_get(&m->values, hash_entity(testing_proc));
|
||||||
GB_ASSERT(found != nullptr);
|
GB_ASSERT(found != nullptr);
|
||||||
|
|
||||||
|
String pkg_name = {};
|
||||||
|
if (testing_proc->pkg != nullptr) {
|
||||||
|
pkg_name = testing_proc->pkg->name;
|
||||||
|
}
|
||||||
|
irValue *v_pkg = ir_find_or_add_entity_string(m, pkg_name);
|
||||||
irValue *v_name = ir_find_or_add_entity_string(m, name);
|
irValue *v_name = ir_find_or_add_entity_string(m, name);
|
||||||
irValue *v_p = *found;
|
irValue *v_p = *found;
|
||||||
|
|
||||||
|
|
||||||
irValue *elem_ptr = ir_emit_array_epi(proc, all_tests_array, cast(i32)i);
|
irValue *elem_ptr = ir_emit_array_epi(proc, all_tests_array, cast(i32)i);
|
||||||
irValue *name_ptr = ir_emit_struct_ep(proc, elem_ptr, 0);
|
irValue *pkg_ptr = ir_emit_struct_ep(proc, elem_ptr, 0);
|
||||||
irValue *p_ptr = ir_emit_struct_ep(proc, elem_ptr, 1);
|
irValue *name_ptr = ir_emit_struct_ep(proc, elem_ptr, 1);
|
||||||
|
irValue *p_ptr = ir_emit_struct_ep(proc, elem_ptr, 2);
|
||||||
|
ir_emit_store(proc, pkg_ptr, v_pkg);
|
||||||
ir_emit_store(proc, name_ptr, v_name);
|
ir_emit_store(proc, name_ptr, v_name);
|
||||||
ir_emit_store(proc, p_ptr, v_p);
|
ir_emit_store(proc, p_ptr, v_p);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-3
@@ -12909,16 +12909,23 @@ void lb_generate_code(lbGenerator *gen) {
|
|||||||
lbValue *found = map_get(&m->values, hash_entity(testing_proc));
|
lbValue *found = map_get(&m->values, hash_entity(testing_proc));
|
||||||
GB_ASSERT(found != nullptr);
|
GB_ASSERT(found != nullptr);
|
||||||
|
|
||||||
|
String pkg_name = {};
|
||||||
|
if (testing_proc->pkg != nullptr) {
|
||||||
|
pkg_name = testing_proc->pkg->name;
|
||||||
|
}
|
||||||
|
lbValue v_pkg = lb_find_or_add_entity_string(m, pkg_name);
|
||||||
lbValue v_name = lb_find_or_add_entity_string(m, name);
|
lbValue v_name = lb_find_or_add_entity_string(m, name);
|
||||||
lbValue v_proc = *found;
|
lbValue v_proc = *found;
|
||||||
|
|
||||||
indices[1] = LLVMConstInt(lb_type(m, t_int), i, false);
|
indices[1] = LLVMConstInt(lb_type(m, t_int), i, false);
|
||||||
|
|
||||||
LLVMValueRef vals[2] = {};
|
LLVMValueRef vals[3] = {};
|
||||||
vals[0] = v_name.value;
|
vals[0] = v_pkg.value;
|
||||||
vals[1] = v_proc.value;
|
vals[1] = v_name.value;
|
||||||
|
vals[2] = v_proc.value;
|
||||||
GB_ASSERT(LLVMIsConstant(vals[0]));
|
GB_ASSERT(LLVMIsConstant(vals[0]));
|
||||||
GB_ASSERT(LLVMIsConstant(vals[1]));
|
GB_ASSERT(LLVMIsConstant(vals[1]));
|
||||||
|
GB_ASSERT(LLVMIsConstant(vals[2]));
|
||||||
|
|
||||||
LLVMValueRef dst = LLVMConstInBoundsGEP(all_tests_array.value, indices, gb_count_of(indices));
|
LLVMValueRef dst = LLVMConstInBoundsGEP(all_tests_array.value, indices, gb_count_of(indices));
|
||||||
LLVMValueRef src = LLVMConstNamedStruct(lbt_Internal_Test, vals, gb_count_of(vals));
|
LLVMValueRef src = LLVMConstNamedStruct(lbt_Internal_Test, vals, gb_count_of(vals));
|
||||||
|
|||||||
Reference in New Issue
Block a user